I've tried all the suggestions I've found here and elsewhere. I've set EnableViewState to true and false for the page. I've set EnableViewState to true and false for the grids. I've tried registering the events for the child grid in the parent grid RowCreated. I am truly at a loss. How do I make this work? Neither the parent or child event is firing.
<%@ 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 in codebehind:
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();
}