여기에서 찾은 모든 제안을 시도해 보았습니다. EnableViewState를 true 및 false로 설정했습니다. EnableViewState를 true 및 false로 설정했습니다. 상위 그리드 RowCreated에 자식 그리드에 대한 이벤트를 등록하려고했습니다. 나는 진실로 상실감에 처해있다. 이 작업을 어떻게 수행합니까? 부모 또는 자녀 이벤트가 실행되지 않습니다.ASP.Net 중첩 된 GridView OnRowCommand가 실행되지 않음
<%@ Control Language="C#" EnableViewState="False" AutoEventWireup="False" CodeBehind="View.ascx.cs" Inherits="IMS.Modules.CreateMerchandise.View" %>
<asp:GridView ID="gvVariants"
runat="server"
AutoGenerateColumns="False"
CssClass="Grid"
DataKeyNames="ID"
OnRowDataBound="gvVariants_OnRowDataBound"
ShowFooter="True"
EnableViewState="False"
OnRowCreated="gvVariants_OnRowCreated"
OnRowCommand="gvVariants_OnRowCommand">
<Columns>
<asp:TemplateField InsertVisible="False">
<ItemStyle HorizontalAlign="Center" Width="30"/>
<ItemTemplate>
<img alt="" style="cursor: pointer; height: 20px; width: 20px;" src="../images/ManageMerchandise/plus.png"/>
<asp:Panel ID="pnlValues" runat="server" Style="display: none" EnableViewState="False">
<asp:GridView
ID="gvValues"
runat="server"
AutoGenerateColumns="False"
CssClass="ChildGrid"
DataKeyNames="ID"
ShowFooter="True"
EnableViewState="False"
OnRowCommand="gvValues_OnRowCommand">
<Columns>
<asp:TemplateField ItemStyle-Width="15px">
<FooterTemplate>
<asp:Button runat="server" text="Add" ID="btnAddValue" CommandName="AddValue" CommandArgument='<%# Bind("ID") %>'/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField
HeaderText="Value"
InsertVisible="True"
ItemStyle-Width="150px">
<ItemTemplate>
<asp:Label ID="lblValue" runat="server"
Text='<%# Bind("VariantValue") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="NewValue" runat="server" Width="150"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Use">
<ItemTemplate>
<asp:CheckBox ID="cbUseVariantValue" runat="server"
Enabled="true"/>
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="cbUseNewVariantValue" runat="server"/>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
<FooterTemplate>
<asp:Button runat="server" text="Add" ID="btnAddVariant" CommandName="addVariant" CommandArgument='<%# Bind("ID") %>'/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Variant" InsertVisible="True">
<ItemTemplate>
<asp:Label ID="lblVarietal" runat="server"
Text='<%# Bind("Name") %>'>
</asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="240"/>
<FooterTemplate>
<asp:TextBox ID="NewVariant" runat="server"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False"/>
</asp:TemplateField>
<asp:TemplateField HeaderText="Use">
<ItemTemplate>
<asp:CheckBox ID="cbUseVariant" runat="server"
Enabled="true"/>
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="cbUseNewVariant" runat="server"/>
</FooterTemplate>
<ItemStyle HorizontalAlign="Center"/>
<FooterStyle HorizontalAlign="Center"/>
</asp:TemplateField>
</Columns>
</asp:GridView>OnLoad:
의 OnLoad : 코드 숨김에서
protected override void OnLoad(EventArgs e)
{
try
{
base.OnLoad(e);
if (!IsPostBack)
{
gvVariants.DataSource = GetVariantTable();
gvVariants.DataBind();
}
}
catch (Exception exc) //Module failed to load
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
}
}
RowDataBound :
protected void gvVariants_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
String variantId= gvVariants.DataKeys[e.Row.RowIndex].Value.ToString();
GridView gvValues = e.Row.FindControl("gvValues") as GridView;
using (var ipv = new IMM_ProductVariantValuesController())
{
ipv.Gets(variantId,"IMM_ProductVariants_ID",pWhere: $"and (portal_id=-1 or portal_id={PortalId})");
ipv.LoadDatatable();
gvValues.DataSource = ipv.Datatable;
gvValues.DataBind();
}
}
}
protected void gvVariants_OnRowCommand(Object sender, GridViewCommandEventArgs e)
{
Response.Write("got here");
Response.End();
}
당신이 gvVariants''에 데이터를 바인딩 할 수 있습니까? 'Page_Load'에 있다면,'if (! IsPostBack)'조건 블록 내에서 처리해야합니다. – ConnorsFan
그게 내가 가진거야 – Chris