开发者

How to change the GridView page Index

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜