|
I tried paging in ASPNET. My code get the lists from the database using stored procedure with entire records. Then, according to the number of pages, the page number should be displayed. I need only limited number of page numbers to be shown in a page.
When, I click next button, next set of page number should be displayed. My stored procedure will return dataset.
This is my code for Paging..
private void doPaging()
{
DataTable dt = new DataTable();
dt.Columns.Add("PageIndex");
dt.Columns.Add("PageText");
for (int i = 0; i <= totalpage; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = i + 1;
dt.Rows.Add(dr);
}
dlPaging.DataSource = dt;
dlPaging.DataBind();
}
This code will display all page numbers once in a page.. Instead I need only 5 page numbers should display once. When I click next button, next 5 page numbers should be displayed
|
|
|
|
|
This is messy. Why do you need a datasource made up of a data table to do this ? A List of numbers is a viable data source. Of course, you're stepping from 0 to the number of pages, you need to change the code to only loop through the numbers you want to show. That seems obvious to me.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Wat abt remaining numbers? How should I use that?
|
|
|
|
|
I don't understand. You said you wanted to only show 5 numbers, so I said then write code to only show those.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
<1 2 3 4 5>
When Clicking the next button, next page number should be displayed. Anyhow, I solved the problem. Thank u
|
|
|
|
|
I m creating a menu in user controller.
When i added user controller in web page.
In mozilla Firefox it is working properly. Like this Image[^]
In Internet Explorer The sub menu goes under the web page. (Position:absolute) Like This[^]
otherwise in Internet Explorer The sub menu show with some white space. (Position:inherit) Like this[^]
Please Help me.
|
|
|
|
|
This is an IE bug. You should look at menu controls that already exist, and how they do it. There's one built in to ASP.NET.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks Christian Graus.
Now I Tried that control in ASP.NET Webpage. It is working properly in IE. and I used Same code block.
But I copied same code and component, & I tried in User-controller but same problem is coming.
How can I come out from this Problem
or Is any alternative way is there???
|
|
|
|
|
OK, the issue is probably to do with what's in your user control. At the end of the day, it's a bug in IE, I've come across it, but I just found another control that didn't do it, I don't know what the actual workaround is.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Actually I m creating a menu. That Menu common for all other web page.
As shown in Picture I want show all product in menu (3 sub menu is there) so is any other component in ASP.NET???
|
|
|
|
|
Hi all,
I'm developing an ASP.Net app with C#. I have a Gridview that I want to show right on page load. I'm then capturing data into the textboxes and need to save it on the gridview right after clicking ADD button.
I can't get my Gridview displayed on page load and when saving the data from the textboxes to the Gridview I get this error:
"Column ‘Full Names’ does not belong to table"
This is what I've got in my code
html Design:
<asp:gridview id="dgInfoProfile1" runat="server" autogeneratecolumns="False">
<columns>
<asp:templatefield headertext="Full Names">
<asp:templatefield headertext="Identifying Number">
<asp:templatefield headertext="Passport Number">
Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
this.dgInfoProfile.DataSource = dt;
dgInfoProfile.DataBind();
}
ADD button:
protected void brtAdd_Click(object sender, EventArgs e)
{
try
{
DataRow dr = dt.NewRow();
dr["Full Names"] = txtFirstName3.Text;
dr["Identifying Number"] = txtIdentityNo.Text;
dr["Passport Number"] = txtPassportNo.Text;
dt.Rows.Add(dr);
//Bind GridView Here with this Table
this.dgInfoProfile.DataSource = dt;
dgInfoProfile.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
I'm not sure where I've missed it, your advice and help in this is highly appreciated.
Thanks.
|
|
|
|
|
Welcome to correct forum.
Nopo wrote: DataRow dr = dt.NewRow();
How come this line is not showing any error.
You have to put
Nopo wrote: DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
in ADD button click.
Just leave GridView.DataBind() in PageLoad.
|
|
|
|
|
I have put:
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
under ADD button click and now my ADD button click looks like:
DataTable dt = new DataTable();
DataRow dr = new DataRow();
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
dr["Full Names"] = txtFirstName3.Text;
dr["Identifying Number"] = txtIdentityNo.Text;
dr["Passport Number"] = txtPassportNo.Text;
dt.Rows.Add(dr);
//Bind GridView Here with this Table
this.dgInfoProfile1.DataSource = dt;
dgInfoProfile1.DataBind();
Now, the app is complaining with this line:
DataRow dr = new DataRow();
error: 'System.Data.DataRow.DataRow(System.Data.DataRowBuilder)' is inaccessible due to its protection level
How am I supposed to define the DataRow?
And as for the gridview on PageLoad, it's not showing still.
|
|
|
|
|
Nopo wrote: DataRow dr = new DataRow();
Why are you doinh this.
1. Create DataTable.
2. Assign Columns to it.
3. Create a DataRow by dt.NewRow().
4. Fill that row and add it to datatable.
|
|
|
|
|
Thanks. Here it is now:
//Create DataTable.
DataTable dt = new DataTable();
//Assign Columns to it.
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
//Create a DataRow by dt.NewRow().
DataRow dr = dt.NewRow();
//Fill that row and add it to datatable.
dr["Full Names"] = txtFirstName3.Text;
dr["Identifying Number"] = txtIdentityNo.Text;
dr["Passport Number"] = txtPassportNo.Text;
dt.Rows.Add(dr);
//Bind GridView Here with this Table
this.dgInfoProfile.DataSource = dt;
dgInfoProfile.DataBind();
I'm making a huge progress now.
After clicking ADD button, the gridview is showing with all the column names but the data captured from the textboxes is not being saved to the gridview.
I'll double check and see if there're any typing errors.
|
|
|
|
|
sure, tell me if it works.
|
|
|
|
|
Its now working perfect. I think the problem was that I turned the AutoGenerateColumns to "false" because after changing it to "true" it worked.
Thanks a lot for all the guidance you've given me.
|
|
|
|
|
If his answer helped you then please vote/rate the messages which helped you.
Thanks !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Great.
|
|
|
|
|
The answer is gr8 been struggle the whole day..thanx
|
|
|
|
|
Forgive me for being confused here, but this actually won't work if you want to keep adding to the datatable based on multiple selections from the textboxes, listboxes and dropdownboxes - right? This will only populate the datagrid once and then re-populate it on each click of the Add button?
|
|
|
|
|
Hi,
I'm looking for a control that does exactly the same as the control used on The Code Project for setting newsletter topics (see http://www.codeproject.com/script/Membership/Modify.aspx tab "Newsletters").
The control, when not selected, shows a comma separated list of newsletter topics. When you click the control it comes up with 4 columns of checkboxes in which you can select and deselect the newsletter topics you're interested in.
Any clues?
|
|
|
|
|
This is Nothing but a DIV . Place all the control inside DIV. Hide/Show Div on the click on TextBox
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Thank you.
You wouldn't happen to have some html / ASP.NET markup would you (especially of the controls used within the DIV)?
I guess the "Hide/Show Div on the click on TextBox" has to be done with Javascript (to prevent a postback)? A small sample script would help a lot.
Thanks for your help.
|
|
|
|
|
Gebbetje wrote:
I guess the "Hide/Show Div on the click on TextBox"
You can do it using simple JavaScript.
Here is the sample javascript :
var counter =0;
function ShowHideDiv()
{
var DivID=document.getElementById('MyDiv');
if(counter == 0)
{
DivID.style.display ="Block";
counter=1;
}
else
{
DivID.style.display ="none";
counter=0;
}
return false;
}
Note: You can also do it without using counter, just check div visibility when you are checking the counter.
Hope this will help you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|