我有一个网格视图:
<asp:GridView ID="gvtransaction" runat="server" AutoGenerateColumns="False" Width="60%" OnRowDataBound="gvtransaction_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="lblfirstname" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lbllastname" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblamount" runat="server" Text='<%# Bind("Amount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Label ID="lblcurrencyID" runat="server" Text='<%# Bind("CurrencyID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Account Name">
<ItemTemplate>
<asp:Label ID="lblcurrencyname" runat="server" Text='<%# Bind("CurrencyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DateCreated">
<ItemTemplate>
<asp:Label ID="lbldatecreated" runat="server" Text='<%# Bind("DateCreated") %>'></asp:Label>
</ItemTemplate>
</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>
这是 onclick = "btnApprove_click() 的代码:
GridViewRow row = ((Button)sender).Parent.Parent as GridViewRow;
string id = ((Label)row.FindControl("lblid")).Text;
Response.Write(row.RowIndex);
string ApprovedStatus = "Approved";
Button btnApprove = (Button)sender;
btnApprove.Enabled = false;
string status = ClassBiller.ConsumerAcceptedStatus(int.Parse(id), ApprovedStatus, DateTime.Now);
ViewPendingConsumer(); //rebind gridview para magEffect yun update
我担心的是,当我单击“批准”按钮或“拒绝”按钮时,如何禁用网格视图中的按钮。
示例场景:当我单击“批准”时,应禁用按钮,以防止用户再次单击该按钮。
我已经阅读了一些建议使用gridview的onrowdatabound的文章..但我对如何做到这一点感到困惑......
我尝试使用
row.Enabled = false;
还是不行……
请帮忙..谢谢