How to change Gridview pages based on the dropdown list selected index? the dropdown list开发者_运维技巧 is not inside the gridview, any help would be appreciated.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
GridView1.PageIndex = DropDownList1.SelectedItem.Value;
GridView1.DataSource = datatable;
GridView1.DataBind();
}
What you need to do is set the GridView's PageSize property to the value of your DropDownList's selected item value:
private void DropDownListPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
gridview.PageSize = DropDownListPageSize.SelectedValue;
}
精彩评论