我需要点击“重新排序”按钮才能保持“重新排序”。当我单击时,“重新排序”出现,但是页面刷新后,重新排序按钮又回来了。
我确实有条件,即“当前数量”不能小于“最小数量”,以便弹出“重新订购”按钮。
.aspx
<asp:TemplateField HeaderText="Reorder" ItemStyle-Width="11%" ItemStyle-CssClass="table" HeaderStyle-CssClass="form-control-sm text-sm-center" HeaderStyle-BackColor="#2E5B89" HeaderStyle-ForeColor="White" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblReorderBy" runat="server" ></asp:Label>
<asp:LinkButton ID="btnReorder" Text="Reorder" runat="server" CssClass="btn btn-primary btn-sm btn-block align-middle" OnClick="btnReorderIcon_Click" CommandName="reorderBy" CommandArgument='<%# Container.DataItemIndex %>' OnDataBinding="btnReorder_DataBinding" OnRowDataBound="btnReorder_RowDataBound" AutoPostback="false"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
aspx.cs
protected void btnReorder_DataBinding(object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
int currQty = 0;
int minQty = 0;
if (Eval("CurrentQuantity").ToString() != "")
{
currQty = Convert.ToInt32(Eval("CurrentQuantity"));
}
if (Eval("MinQuantity").ToString() != "")
{
minQty = Convert.ToInt32(Eval("MinQuantity"));
}
if (currQty <= minQty)
{
lb.Visible = true;
}
else if (currQty == 0)
{
lb.Visible = false;
}
else
{
lb.Visible = false;
}
}
protected void btnReorderIcon_Click(object sender, EventArgs e)
{
String qs = "";
LinkButton btnReorder = (sender) as LinkButton;
Label lblReorderBy = (sender) as Label;
GridViewRow gvr = (GridViewRow)btnReorder.NamingContainer;
int rowIndex = gvr.RowIndex;
btnReorder.Text = "<span class=\"fa fa-truck\"></span> Reordered";
DateTime now = DateTime.Now;
}