A
antonyliu2002
I've been googling for some time, and could not find the solution to
this problem.
I am testing the paging feature of gridview. I have a very simple web
form on which the user can select a few fields to be included in the
table, which is to be bound to the gridview.
The web form looks like so (Don't worry about the stupidity of this
web form for now.):
Check stuffs you wanna include in the table:
[] Customer ID
[] Customer Last Name
[] Customer First Name
[] Customer Email
[] Customer Phone
[Click this button to show the table]
[---- the paging-enabled gridview is right here ------]
The gridview is declared like so:
<asp:GridView ID="GridView1"
EnableViewState="true"
EnableSortingAndPagingCallbacks="true"
DataSourceID="SqlDataSource1"
runat="server"
AllowPaging="True"
AllowSorting="true">
</asp:GridView>
In the code-behind (in C#), I pass the programmatically created SQL
select command to the SqlDataSource like so:
SqlDataSource1.SelectCommand = theSelectCommandCreatedOnTheFly;
Now, after the user clicks the button to create the customer report,
the gridview is populated with customer data with the expected fields.
But, when the paging index is clicked, the gridview disaapears. One
short note from a blog says that gridview will disappear between
postbacks. So, this might be the cause.
I guess I don't need to implement a GridView1_OnPageIndexChanging
method to handle the paging event since I don't think I am manually
binding the gridview to the dataset.
How do we handle this problem? Thanks.
this problem.
I am testing the paging feature of gridview. I have a very simple web
form on which the user can select a few fields to be included in the
table, which is to be bound to the gridview.
The web form looks like so (Don't worry about the stupidity of this
web form for now.):
Check stuffs you wanna include in the table:
[] Customer ID
[] Customer Last Name
[] Customer First Name
[] Customer Email
[] Customer Phone
[Click this button to show the table]
[---- the paging-enabled gridview is right here ------]
The gridview is declared like so:
<asp:GridView ID="GridView1"
EnableViewState="true"
EnableSortingAndPagingCallbacks="true"
DataSourceID="SqlDataSource1"
runat="server"
AllowPaging="True"
AllowSorting="true">
</asp:GridView>
In the code-behind (in C#), I pass the programmatically created SQL
select command to the SqlDataSource like so:
SqlDataSource1.SelectCommand = theSelectCommandCreatedOnTheFly;
Now, after the user clicks the button to create the customer report,
the gridview is populated with customer data with the expected fields.
But, when the paging index is clicked, the gridview disaapears. One
short note from a blog says that gridview will disappear between
postbacks. So, this might be the cause.
I guess I don't need to implement a GridView1_OnPageIndexChanging
method to handle the paging event since I don't think I am manually
binding the gridview to the dataset.
How do we handle this problem? Thanks.