这是我的代码:
<asp:GridView ID="AccountBindingDGV" runat="server" SkinID="gridviewSkin"
OnRowDataBound="AccountBindingDGV_RowDataBound" ShowFooter="True" AutoGenerateColumns="False"
OnDataBound="AccountBindingDGV_DataBound"
<Columns>
<asp:BoundField DataField="UserName" HeaderText="UserName" />
<asp:BoundField DataField="WebsiteAccount" HeaderText="WebsiteAccount" />
<asp:TemplateField HeaderText="Remove" ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Remove" runat="server" Text="Remove" CssClass="ButtonCss1" CommandArgument='<%# Bind("ID") %>'
OnClick="RemoveButton_Click" OnClientClick="return confirm('Are you sure to REMOVE this account?')" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Add" ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Add" runat="server" Text="Add" CssClass="ButtonCss1" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我在执行AccountBindingDGV_RowDataBount
时执行了一些操作:
我需要Remove.CommandArgument携带的ID来删除一条记录,但它的值为空。我调试AccountBindingDGV_RowDataBount
并发现这些删除按钮具有正确的值?我不知道为什么?
有什么好主意吗?