Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1370
Childs are not populated on postback or expand button is not rendered
posted

Hi,

I got a problem on a WHDG with paging and binding on code behind. 
Childs are not filled after a post back.  

here the code :       

namespace WebApplication1
{
     public partial class Default : System.Web.UI.Page
    {
 
        public DataSet countryCustomersDataSet
        {
            get { if (Session["MyDataSet"] != null) return (DataSet)Session["MyDataSet"]; else return null; }
            set { Session["MyDataSet"] = value; } 
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDataSet(true);
                this.MyGrid.DataMember = "Root";
                this.MyGrid.DataKeyFields = "Id";
 
            }
            this.MyGrid.DataSource = countryCustomersDataSet;
            this.MyGrid.DataBind();
        }
 
        private void LoadDataSet(bool reload)
        {
            if (!reload)
                return;
            DataSet ds = new DataSet();
 
            DataTable dt = new DataTable("Root");
            dt.Columns.Add("Id");
            dt.Columns.Add("BirthDate", typeof(DateTime));
            dt.Columns.Add("Name");
            dt.Rows.Add(new object[] { 101, "11/09/1980", "Chandradeep" });
            dt.Rows.Add(new object[] { 102, "11/10/1970", "MikeS" });
            dt.Rows.Add(new object[] { 103, "11/12/1875", "Luke" });
            dt.Rows.Add(new object[] { 104, "11/2/1988", "Sam" });
 
            // Child DataRecords.
            DataTable dt1 = new DataTable("Children1");
            dt1.Columns.Add("IdParent");
            dt1.Columns.Add("BirthDate");
            dt1.Columns.Add("Name");
 
            dt1.Rows.Add(new object[] { 101, "11/09/1980", "1Chandradeep" });
            dt1.Rows.Add(new object[] { 101, "11/09/1981", "1Chandradeep 2" });
            dt1.Rows.Add(new object[] { 101, "10/09/1979", "1Chandradeep 3" });
            dt1.Rows.Add(new object[] { 101, "11/09/1982", "1Chandradeep 4" });
 
            dt1.Rows.Add(new object[] { 102, "11/09/1980", "2MikeS" });
            dt1.Rows.Add(new object[] { 102, "11/09/1999", "2Step In" });
            dt1.Rows.Add(new object[] { 102, "11/12/1951", "2Step Out" });
 
            dt1.Rows.Add(new object[] { 103, "11/09/1980", "3Sandeep Patil" });
            dt1.Rows.Add(new object[] { 103, "11/09/1980", "3Step Out" });
 
            dt1.Rows.Add(new object[] { 104, "11/09/1980", "4Sandeep Patil" });
            dt1.Rows.Add(new object[] { 104, "11/09/1980", "4Step Out" });
            dt1.Rows.Add(new object[] { 104, "11/09/1980", "4Sandeep Patil" });
            dt1.Rows.Add(new object[] { 104, "11/09/1980", "4Step Out" });
  
            //Tables added to the Collections of DataSet
            ds.Tables.Add(dt);
            ds.Tables.Add(dt1);
             ds.Relations.Add(new DataRelation("relation1", dt.Columns[0], dt1.Columns[0]));
             countryCustomersDataSet = ds;
  
        }
 
        protected void btnTest_Click(object sender, EventArgs e)
        {
            lblResultat.Text = ((Button)sender).CommandArgument;
        }
    }
}

 
ASPX :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" EnableEventValidation="false" Inherits="WebApplication1.Default" %>
 
<%@ Register assembly="Infragistics4.Web.v10.2, Version=10.2.20102.2129, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.GridControls" tagprefix="ig" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Label ID="lblResultat" runat="server" ></asp:Label>
         <ig:WebHierarchicalDataGrid ID="MyGrid" runat="server"  EnableViewState="true"
             DataMember="Root"  AutoGenerateBands="true" DataKeyFields="Id" AutoGenerateColumns="true" Key="parent"
            InitialDataBindDepth="-1" InitialExpandDepth="-1" Width="100%"
            >
            <Bands>
                <ig:Band Key="details" DataMember="Children1" DataKeyFields="IdParent" AutoGenerateColumns="false" >
                    <Columns >
                        <ig:BoundDataField DataFieldName="Name" Key="keyName"></ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="BirthDate" Key="keyBirthDate"></ig:BoundDataField>
                        <ig:TemplateDataField Key="btnTest">
                            <ItemTemplate>
                                <asp:Button OnClick="btnTest_Click" runat="server" ID="btnTest" CommandArgument='<%# Eval("Name") %>' Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Name") %>' />
                            </ItemTemplate>
                        </ig:TemplateDataField>
                    </Columns>
                </ig:Band>
            </Bands>
 
         <Behaviors>
            <ig:Paging Enabled="true" PageSize=2></ig:Paging>
         </Behaviors>
    </ig:WebHierarchicalDataGrid>
 
    </div>
    </form>
</body>
</html>

 

When I click on button, the button postback event will be good but child will disappear and the expand button is not rendered

Why ?