Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 13, 2008 08:44 PM by ronald_yoh
May 22, 2008 06:14 PM|LINK
I have a simple task , I have a grid view. I' m having to write the page index changing event to bind the items in the next page to the grid. For this task I' m using this method. This event is fired. It goes through every step of this method and does nothing
meaning it does not get the items for the next page. Can you please help?
Search(); //I' m using this method to find all the items I need to be posted in my grid.
gvSearchItems.PageIndex = e.NewPageIndex ;
May 22, 2008 06:23 PM|LINK
Are you programmatically data-binding your GridView? If so, does the Search method set the GridView's DataSource property? The GridView.DataSource property needs be set once againg prior to calling the GridView.DataBind method.
May 22, 2008 06:34 PM|LINK
Thanks a lot for your quick response.Yes the search method gets the datatable and search method calls another method binditems whihc binds the datatable to the Grid view and here is the code for the two methods.
gvSearchItems.DataSource = dt;
gvSearchItems.PageSize = Profile.ItemResutsPerPage;
dlSearchItems.DataSource = dt;
from = Profile.ItemResutsPerPage * gvSearchItems.PageIndex + 1;
to = dt.Count;
to = from + Profile.ItemResutsPerPage - 1;
//My search method.
listFrom = -1000;
listTo = 999999;
firstFrom = -1000;
firstTo = 999999;
division, category, classVal, line,
from, to, listFrom, listTo, firstFrom, firstTo, txtCustomerProposal.Text, txtPONum.Text);
May 22, 2008 08:25 PM|LINK
I found out... [:)]
Thid gridview was in an update panel with updatemode as conditional so I had to add the async postback event as Databinding for the GridView.
Nov 12, 2008 11:50 PM|LINK
hey mate.. i think i'm the same issue as you did... i'm trying to bind the datagrid from excel file.. when I click on the page number, it doesn't display anything. I know i have to re-bind the datasource but how do i achieve this? do I need to open connection
for that excel again?
Nov 13, 2008 03:42 PM|LINK
If that connection is closed. But just to bind the data you should not have to worry about the connection if there is a method fetching this dataset for you. If you have written it all in the code behind file ...
even then I would say put the lines of code fetching the data set into a method and call it as many times as you want to bind the data. That way the code is more readable and it also reduces the lines of repititive code. Hope I answered your question.
Nov 13, 2008 08:44 PM|LINK