Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gridview_paging messing up

I have an asp.net C# web app. In it I have a gridview. The gridview gets search results from a database. Sometimes there are a lot of results, and so I wanted to use paging. Here's what I tried:

     protected void grdResults_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdResults.PageIndex = e.NewPageIndex;
        grdResults.DataBind();
    }

For some reason, when I click on a page number, it shows me the EmptyDataText(There are no records to display). What code would work? Please help.

Thank you

like image 1000
zohair Avatar asked Feb 26 '26 15:02

zohair


1 Answers

Try assigning the datasource in NeedDataSource event.

Cheers.

like image 54
Zinx Avatar answered Mar 01 '26 05:03

Zinx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!