在客户端过滤

时间:2013-06-14 08:48:46

标签: javascript jquery asp.net

您好我有三个复选框和一个gridview(使用模板)。 我正在使用我的复选框来过滤gridview的行(帐户)的状态。我可以在服务器端过滤gridview,现在我想要发生的是通过客户端过滤gridview,其中当用户选中其中一个复选框时,它将显示具有Pending,Approved或Rejected的帐户而不刷新页面。我怎样才能在jquery或javascript中执行此操作。

我还没有代码,因为我不知道如何开始。

这是我的复选框:

<asp:CheckBox ID="Pending" runat="server" Text="Pending" AutoPostBack="True" OnCheckedChanged="PendingConsumer_CheckedChanged" />
        <asp:CheckBox ID="Approved" runat="server" Text="Approved" AutoPostBack="True" OnCheckedChanged="ApprovedConsumer_CheckedChanged" />
        <asp:CheckBox ID="Rejected" runat="server" Text="Rejected" AutoPostBack="True" OnCheckedChanged="RejectedConsumer_CheckedChanged" />

这是我的gridview(我在后面的代码中出价):

<asp:GridView ID="gvconsumer" runat="server" AutoGenerateColumns="False" Width="50%" OnRowDataBound="gvconsumer_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="">
                    <ItemTemplate>
                    <asp:Label ID="lblid" runat="server" Text='<%# Bind("id") %>' Visible="false" ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Consumer">
                    <ItemTemplate>
                    <asp:Label ID="lblconsumer" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                    <asp:Label ID="lblname" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                    <asp:Label ID="lblstatus" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="DateCreated">
                    <ItemTemplate>
                    <asp:Label ID="lbldatecreated" runat="server" Text='<%# Bind("DateCreated") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="">
                    <ItemTemplate>
                    <asp:Button ID="btnApprove" runat="server" Text="Approve" OnClick="btnApprove_Click" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="">
                    <ItemTemplate>
                    <asp:Button ID="btnReject" runat="server" Text="Reject" OnClick="btnReject_Click" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

这是我的过滤器:

        int MerchantFilterID = int.Parse(Session["userid"].ToString());
    string sqlfilter = "id >= 1";
    DataView dv = new DataView(ClassBiller.FilterPendingConsumer(MerchantFilterID));

    if (Pending.Checked)
    {
        sqlfilter += " AND (Status = 'Pending')";
    }

    if (Approved.Checked)
    {
        sqlfilter += (sqlfilter.Contains("AND") ? "OR" : "AND") + " (Status = 'Approved')";
    }

    if (Rejected.Checked)
    {
        sqlfilter += (sqlfilter.Contains("AND") ? "OR" : "AND") + " (Status = 'Rejected')";
    }

    dv.RowFilter = sqlfilter;

    gvconsumer.DataSource = dv;
    gvconsumer.DataBind();
过滤器

使用FilrterConsumer =“SELECT ConsumerBiller.id,ConsumerMaster.LastName,ConsumerMaster.FirstName,ConsumerBiller.Status,ConsumerBiller.DateCreated”                                    +“来自ConsumerMaster”                                    +“在ConsumerMaster.id上加入ConsumerBiller = ConsumerBiller.ConsumerID”                                    +“WHERE Con​​sumerBiller.MerchantID = @MerchantID AND ConsumerBiller.Status&lt;&gt;'DELETED'AND ConsumerBiller.Status&lt;&gt;'CANCELED'”;

        string[] param = { "@MerchantID" };
        object[] paramVal = { MerchantID };

        return ClassDBQuery.ExecDataReader(FilrterConsumer, param, paramVal);

0 个答案:

没有答案