从deleterow方法之外的gridview中删除一行

时间:2015-02-04 10:04:07

标签: c# asp.net gridview

我想删除RowDeleting方法之外的一行。 我试图这样做,但它要求发件人和行删除,但我收到转换错误。

无法将类型gridview行转换为gridview delete event args

这是我的代码,你注意到有什么不对吗?

grdContact_RowDeleting((object)grdContact, (GridViewDeleteEventArgs)grdContact.Rows[0]);





protected void grdContact_RowDeleting(object sender, GridViewDeleteEventArgs e)
{            
    List<DettagliFattura> app = (List<DettagliFattura>)Session["lst_dettagli"];
    app.RemoveAt(e.RowIndex);

    Session["lst_dettagli"] = app;
    FillGrid();
    CalcolaTotale();
}

1 个答案:

答案 0 :(得分:0)

使用tr和td

使用如下所示的空模板
<EmptyDataTemplate>
                                            <tr>
                                                <td>
                                                    <asp:TextBox runat="server" ID="coursetxt"></asp:TextBox>

                                                </td>
                                                <td>
                                                    <asp:Label ID="lbladd3" runat="server"></asp:Label>
                                                    <asp:TextBox runat="server" ID="Universitytxt"></asp:TextBox>

                                                </td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="sdatetxt"></asp:TextBox>

                                                </td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="endtxt"></asp:TextBox>

                                                </td>
                                                <td>
                                                    <asp:Button ID="btnInsertRecordedu" runat="server" CssClass="buttonpop" Text="Add" ValidationGroup="edu" CommandName="Insert_emptydatatemplate" /></td>
                                            </tr>
                                        </EmptyDataTemplate>