2
我有一個UpdatePanel一個GridView像波紋管:的UpdatePanel和GridView
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" GridLines="None"
AllowPaging="True" OnRowCommand="GridViewAllProducts_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img id="imgImage" src='<%# Bind("Image") %>' class="imgNewsAllNewsUC noBorder" alt=""
runat="server" />
<asp:ImageButton ID="ibDelete" CommandName="delete" CommandArgument='<%# Bind("Id") %>'
runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
和代碼背後,是像波紋管:
protected void GridViewAllProducts_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "delete")
{
new ProductC().DeleteBy_Id(Convert.ToInt32(e.CommandArgument));
GridViewAllProducts.DataSource = new ProductC().GetAllProducts();
GridViewAllProducts.DataBind();
}
}
當我點擊ibDelete,相關行已刪除數據庫,但該頁面在我刷新頁面之前不會更改。我哪裏錯了?
它應該是 如果(e.CommandName == 「刪除」) 公告中刪除的大字母d – kskjon