Urgent-Please help me.

S

settyv

Hi,

I have webform which has 4 Datagrid controls with (built-in
Pagination) and 4 search buttons to perform the search operation.When i
click on search operation it is displaying the results in grid .when i
click next it is telling error...Please let me know how to solve this
problem.


Below method can be used for all the datagrids.
protected void NewPage(object sender, DataGridPageChangedEventArgs e)
{
Control ctl=new Control() ;

if (ctl.ID.ToString() == "grdCaseSearch" )
{
grdCaseSearch.CurrentPageIndex = e.NewPageIndex;
DisplayCaseSearchResults();
}
else if (ctl.ID.ToString() == "grdCalSearch" )
{
grdCalSearch.CurrentPageIndex = e.NewPageIndex;
DisplayCalendarSearchResults ();
}

}

<asp:datagrid id="grdCaseSearch" PagerStyle-PrevPageText="Previous"
PagerStyle-NextPageText="Next" PagerStyle-Mode="NextPrev"
OnPageIndexChanged="NewPage" AllowPaging="True"
Headerstyle-BackColor="#ccccff " Runat="server"></asp:datagrid>


<asp:datagrid id="grdCalSearch" PagerStyle-PrevPageText="Previous"
PagerStyle-NextPageText="Next" PagerStyle-Mode="NextPrev"
OnPageIndexChanged="NewPage" AllowPaging="True"
Headerstyle-BackColor="#ccccff " Runat="server"></asp:datagrid>




Thanks,
Vishnu
 
O

Onwuka Emeka

Sorry i saw this pretty late, don't know if you have got a solution, going
through your code i came over a couple of gotchas that could be issues,
since you
did not state the excat error you are getting

first the lines

Control ctl=new Control() ;
if (ctl.ID.ToString() == "grdCaseSearch" )

ctl would never be equal to "grdCaseSearch"

maybe this is what you were trying to achieve :

protected void NewPage(object sender, DataGridPageChangedEventArgs e) {
DataGrid ctl= sender as DataGrid;
if ( ctl != null && (ctl.ID.ToString() == "grdCaseSearch") ){
ctl.CurrentPageIndex = e.NewPageIndex;
DisplayCaseSearchResults();
}
.....
}

secondly you might want to check to make sure that your NewPageIndex is not
greater than the size of the result set
vis

if (e.NewPageIndex >= ctl.PageSize)
{
ctl.CurrentPageIndex = 0;
}
else
{
ctl.CurrentPageIndex = e.NewPageIndex ;
}

hope these help, however if you post the errors you are getting it'll be a
lot easier tracking down what the problem is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top