Firecat1970
IS-IT--Management
Dear experts,
On my page, I have a button and a GridView.
When I press the button, the GridView is shown with the data, however the page feature does not work, if I press the 2nd or 3rd page, the GridView disappear....
However, if I move the btnCode_OnClick context to Page_Load, then the page feature of the GridView is working properly...
What have I missed? How can I make GridView perform properly when its datasource is bind at runtime conditionally?
Thanks!
public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCode_Click(object sender, ImageClickEventArgs e)
{
int nCount;
TList<Customers> CustomerList = new TList<Customers>();
CustomersService CustomerService = new CustomersService();
CustomerList = CustomerService.GetPaged(out nCount);
gvResult.DataSource = CustomerList;
gvResult.DataBind();
}
protected void gvResultOnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvResult.PageIndex = e.NewPageIndex;
gvResult.DataBind();
}
}
On my page, I have a button and a GridView.
When I press the button, the GridView is shown with the data, however the page feature does not work, if I press the 2nd or 3rd page, the GridView disappear....
However, if I move the btnCode_OnClick context to Page_Load, then the page feature of the GridView is working properly...
What have I missed? How can I make GridView perform properly when its datasource is bind at runtime conditionally?
Thanks!
public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCode_Click(object sender, ImageClickEventArgs e)
{
int nCount;
TList<Customers> CustomerList = new TList<Customers>();
CustomersService CustomerService = new CustomersService();
CustomerList = CustomerService.GetPaged(out nCount);
gvResult.DataSource = CustomerList;
gvResult.DataBind();
}
protected void gvResultOnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvResult.PageIndex = e.NewPageIndex;
gvResult.DataBind();
}
}