我有一个带有 2 个子网格视图的网格视图“GridViewTtransmittals”
Child 1: GridViewTranstoCon (parent GridViewEfile)
Child 2: GridViewEfile
GridViewEfile(child2)本身是child1“GridViewEfile”的孩子现在我想定义GridViewEfile_RowDeleting但我有错误(GridViewTranstoCon'在当前上下文中不存在)请帮助是什么问题?
protected void GridViewEfile_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridView Efile = sender as GridView;
var parentrow1 = (GridViewRow)Efile.Parent.Parent;
var parentrow2 = (GridViewRow)Efile.Parent.Parent.Parent;
// int transid = Convert.ToInt32(GridViewTtransmittals.DataKeys[e.RowIndex].Value);
int transid = Convert.ToInt32(GridViewTtransmittals.DataKeys[parentrow2.RowIndex].Value);
GridView GridViewTranstoCon = GridViewTtransmittals.FindControl("GridViewTranstoCon") as GridView;
int transmittoconid = Convert.ToInt32(GridViewTranstoCon.DataKeys[parentrow1.RowIndex].Value);
int FileId = Convert.ToInt32(Efile.DataKeys[e.RowIndex].Value);
//Also step into this and see what it's doing
OnDeleteEfile(FileId, transmittoconid, transid);
}
标记如下:
<asp:GridView ID="GridViewTtransmittals" runat="server" AutoGenerateColumns="False"
BorderStyle="None" ShowHeader="False" Width="100%" DataKeyNames="TransID" onrowdatabound="GridViewTtransmittals_RowDataBound"
onrowdeleting="GridViewTtransmittals_RowDeleting">
<columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="Transmittal" AutoPostBack="True"
OnCheckedChanged="RadioButton1_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:hyperlinkfield DataNavigateUrlFields="TransId"
DataNavigateUrlFormatString="~/Copy of Transmittal.aspx?TransId={0}" DataTextField="TRANSMITTAL"
HeaderText="Transmittal" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="true" />
<asp:TemplateField HeaderText = "TRANSMITtoCon">
<ItemTemplate>
<asp:GridView ID="GridViewTranstoCon" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#000000" GridLines="Both" onrowdeleting="GridViewTranstoCon_RowDeleting" DataKeyNames="TransmittoconID">
<AlternatingRowStyle BackColor="Yellow" />
<Columns>
<asp:BoundField DataField="TRANSMITtoCon" HeaderText= "TRANSMITtoCon" >
<ItemStyle Width = "20%" />
</asp:BoundField>
<asp:CommandField ButtonType="Button" ShowDeleteButton="true" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Red" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "E-FILES">
<ItemTemplate>
<asp:GridView ID="GridViewEfile" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#000000" GridLines="Both" DataKeyNames="FileID">
<AlternatingRowStyle BackColor="Yellow" />
<Columns>
<asp:TemplateField HeaderText = "E-FILES">
<ItemTemplate>
<asp:LinkButton HeaderText = "E-FILES" ID="LinkButton1" runat="server" OnCommand="LinkButton1_Command" CommandName="Download" CommandArgument='<%#Eval("FileID")%>'><%#Eval("FileName")%> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" ShowDeleteButton="true" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Red" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
</columns>