筛选后的Gridview分页问题? [英] Filtered Gridview Paging Problem?

查看:52
本文介绍了筛选后的Gridview分页问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个问题,我做了一个gridview,我正在根据用户从下拉列表中选择的内容来过滤gridview的内容...我也在gridview中使用分页,它一次显示10行...现在当我从下拉列表中选择内容时,grideview内容过滤器并且如果过滤器内容超过10行,则会发生分页...并且当我单击下一页时,gridview显示的是下一页的内容,而不是内容过滤后的grideview下一页?

请帮助我如何对gridview的过滤内容进行分页??

hi everyone,

i have a problem, i made a gridview and i am filtering the grideview content on the bases of selected content by the user from dropdownlist... i am also using paging in the gridview, it shows 10 rows at a time...now when i select the content from the dropdownlist the grideview content filters and if the filter content is more than 10 rows paging occurs...and when i click on the next page the gridview shows the content of next page but not the content of filtered grideview next page??

please help me how can i do paging on filtered content of the gridview???

推荐答案

您好,
我不知道您使用什么数据源来填充GridView.但是,尽管有数据源的类型(ObjectDataSource,SqlDataSource或...),您仍需要为这些源设置filter参数,以便在回发时对其进行过滤.

希望对您有帮助,
干杯.
Hi,
I do not know what datasource you use to fill your GridView. However, despite the type of the datasource(ObjectDataSource, SqlDataSource, or ...) you need to set filter parameter for these sources to filter them on very postback.

I hope it helps,
Cheers.



试试这个例子会给Idea带来希望,希望它对您有帮助
Hi ,
Try this example will give Idea ,Hope it help you
protected void Page_Load(object sender, EventArgs e)
{

}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    if (ViewState["flag"] !=null)
    {
        if ((bool)ViewState["flag"] == true)
        {
            SqlDataSource1.FilterExpression = "Item_name like '%trr4%'";
        }
    }
}
protected void Button1_Click(object sender, EventArgs e)
{
    ViewState.Add("flag", true);

    SqlDataSource1.FilterExpression = "Item_name like '%trr4%'";
    GridView1.DataSourceID = "";
    GridView1.DataSourceID = "SqlDataSource1";
    //GridView1.DataSource = SqlDataSource1;
    GridView1.DataBind();
}





<div>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"

        AutoGenerateColumns="False" DataKeyNames="item_code"

        DataSourceID="SqlDataSource1" onpageindexchanging="GridView1_PageIndexChanging"

        PageSize="3">
        <Columns>
            <asp:BoundField DataField="item_code" HeaderText="item_code"

                InsertVisible="False" ReadOnly="True" SortExpression="item_code" />
            <asp:BoundField DataField="Item_name" HeaderText="Item_name"

                SortExpression="Item_name" />
            <asp:BoundField DataField="brand" HeaderText="brand" SortExpression="brand" />
            <asp:BoundField DataField="size" HeaderText="size" SortExpression="size" />
            <asp:BoundField DataField="section" HeaderText="section"

                SortExpression="section" />
            <asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
            <asp:BoundField DataField="Material" HeaderText="Material"

                SortExpression="Material" />
            <asp:BoundField DataField="Qty" HeaderText="Qty" SortExpression="Qty" />
            <asp:BoundField DataField="tax" HeaderText="tax" SortExpression="tax" />
            <asp:BoundField DataField="tt" HeaderText="tt" SortExpression="tt" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"

        ConnectionString="<%


ConnectionStrings:testConnectionString %> ; " span> SelectCommand =" 选择*来自[Items]" < /asp:SqlDataSource > < br > < asp:Button ID =" runat 服务器" onclick Button1_Click" 文本 按钮" / > < /div >
ConnectionStrings:testConnectionString %>" SelectCommand="SELECT * FROM [Items]"></asp:SqlDataSource> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> </div>




最好的问候
米特瓦里(M.Mitwalli)




Best Regards
M.Mitwalli


这篇关于筛选后的Gridview分页问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆