嗨,我有三个复选框和一个 gridview(使用模板)。我正在使用我的复选框来过滤 gridview 的行(帐户)的状态。我可以在服务器端过滤gridview,现在我想要通过客户端过滤gridview,其中当用户选中其中一个复选框时,它将显示具有待处理、已批准或已拒绝的帐户而不刷新页面。我怎样才能在 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 =“选择 ConsumerBiller.id、ConsumerMaster.LastName、ConsumerMaster.FirstName、ConsumerBiller.Status、ConsumerBiller.DateCreated”+“FROM ConsumerMaster”+“在 ConsumerMaster.id 上加入 ConsumerBiller = ConsumerBiller.ConsumerID”+“WHERE ConsumerBiller.MerchantID = @MerchantID AND ConsumerBiller.Status <> 'DELETED' AND ConsumerBiller.Status <> 'CANCELLED'";
string[] param = { "@MerchantID" };
object[] paramVal = { MerchantID };
return ClassDBQuery.ExecDataReader(FilrterConsumer, param, paramVal);