我想通過輸入類型=「圖像」和該圖像相關聯的行的ID刪除GridView中的一行,所以如果你點擊該圖像,它會調用一個函數在asp中。並根據該ID從數據庫中刪除該記錄並重新加載該網格。 解決這個問題的最好方法是什麼?謝謝你的幫助。刪除GridView行
<asp:GridView ID="grdHouses" runat="server"
CssClass="gridview"
RowStyle-CssClass="gridview_itm"
AlternatingRowStyle-CssClass="gridview_aitm"
HeaderStyle-CssClass="gridview_hdr" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="" ItemStyle-Width="2%">
<ItemTemplate>
<input type="image" name="imgDelete" class="listViewTdToolsS1" src="../App_Themes/Sugar2006/images/delete_inline.gif" alt="rem" style="height:12px;width:12px;border-width:0px;" value=""
<%# DataBinder.Eval(Container.DataItem, "ID") %>">
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="Name_SortLnkBtn" runat="server" Text="NAME" ToolTip="Click to Sort Column" CommandName="Sort" CommandArgument="Name" CausesValidation="false" />
<asp:ImageButton ID="Name_SortImgBtn" runat="server" Visible="false" ToolTip="Click to Sort Column" CommandName="Sort" CommandArgument="Name" CausesValidation="false" />
</HeaderTemplate>
<ItemTemplate>
<%#Eval("Name")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="Description_SortLnkBtn" runat="server" Text="DESCRIPTION" ToolTip="Click to Sort Column" CommandName="Sort" CommandArgument="Description" CausesValidation="false" />
<asp:ImageButton ID="Description_SortImgBtn" runat="server" Visible="false" ToolTip="Click to Sort Column" CommandName="Sort" CommandArgument="Description" CausesValidation="false" />
</HeaderTemplate>
<ItemTemplate>
<%#Eval("Description")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
添加的DataKeyNames = 「ID」 中的GridView – Amitesh 2014-08-25 09:51:54