I have a DataGrid set up with a list of projects shown, I have a drop down list with three options, “15” Results, “25” Results and “All”. I have a method in the cs OnSelectedIndexChanged that should change the paging setup for the DataGrid, I have checked the value that is passed to the method and it is correct, however, when I run the application and select an option from the drop down list nothing happens.
Does anyone know why this might be happening? Can paging for a DataGrid only be specified on PageLoad?? Or am I just completely approaching this problem the wrong way…..
Thanks in advance for any help!
This is my method in the code behind
protected void ddlShowIncomplete_OnSelectedIndexChanged(Object sender,EventArgs e)
{
if (ddlShowIncomplete.SelectedValue == "15")
{
dgRequests.AllowPaging = true;
dgRequests.PageSize = 5;
}
else if (ddlShowIncomplete.SelectedValue == "25")
{
dgRequests.AllowPaging = true;
dgRequests.PageSize = 2;
}
else if (ddlShowIncomplete.SelectedValue == "All")
{
dgRequests.AllowPaging = false;
}
else
{
}
}
You need to rebind the data grid after changing the page size. Add
at the end of your method.