aspx页面:
<asp:GridView ID="CompangStoreList" runat="server" AutoGenerateColumns="False" EnableModelValidation="True" ShowHeader="False"onrowcommand="CompangStoreList_RowCommand" > <Columns> <asp:BoundField DataField="StoreID" Visible="False" /> <asp:BoundField DataField="StoreName" /> <asp:TemplateField ShowHeader="False"> <ItemTemplate> <asp:Button ID="btnLoggin" runat="server" CausesValidation="false" CommandName="Loggin" Text="Loggin" CommandArgument='<%# Bind("StoreID") %>'/> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
后台cs:
protected void CompangStoreList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Loggin") { STORE_ID = e.CommandArgument.ToString(); } }
问题是 不会触发后台这个方法·
那就用linkbutton吧