开发者

How to change the GridView page Index

开发者 https://www.devze.com 2023-02-14 23:32 出处:网络
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=\"DropDownLis

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消