Hello
I have a WHDG binds to flat dataset. I make the relations via WHDS. If I set InitialDataBindDepth property to 1 there is no problem it can bind the child row without problems. But I want to bind the data with LoadOnDemand method. So if I set the InitialDataBindDepth to 0, it can see which parent record has child but it cannot bind data.
Here is my code (C#)
dsMessages = Messages.MesajGetir(RezervasyonRef, 3, 1); dsKullanici = Messages.KisiGetir(RezervasyonRef, 0, 1); dtMessages = dsMessages.Tables[0]; dtMessages.TableName = "tableMesaj"; dtKullanici = dsKullanici.Tables[0]; dtKullanici.TableName = "tableKisi"; Infragistics.Web.UI.DataSourceControls.DataView dvKisi = new Infragistics.Web.UI.DataSourceControls.DataView(); dvKisi.ID = "vBaslik"; dvKisi.DataMember = "tableKisi"; dvKisi.DataSource = dtKullanici;
#region comment dvMesaj Infragistics.Web.UI.DataSourceControls.DataView dvMesaj = new Infragistics.Web.UI.DataSourceControls.DataView(); dvMesaj.ID = "vMesaj"; dvMesaj.DataMember = "tableMesaj";
dvMesaj.DataSource = dtMessages;
whdsShowMessages.DataRelations.Clear(); whdsShowMessages.DataViews.Clear(); whgridShowMessages.Rows.Clear();
whdsShowMessages.DataViews.Add(dvKisi); whdsShowMessages.DataViews.Add(dvMesaj);
Infragistics.Web.UI.DataSourceControls.DataRelation drel = new Infragistics.Web.UI.DataSourceControls.DataRelation("vBaslik", "ID", "vMesaj", "ID"); whdsShowMessages.DataRelations.Add(drel); #endregion whgridShowMessages.DataSource = whdsShowMessages; whgridShowMessages.DataBind();
and here is the (.aspx)
<ig:WebHierarchicalDataSource ID="whdsShowMessages" runat="server"> </ig:WebHierarchicalDataSource> <ig:WebHierarchicalDataGrid ID="whgridShowMessages" runat="server" InitialDataBindDepth="0" Width="100%" DataKeyFields="ID" AutoGenerateColumns="False" Key="whgridShowMessages" AutoGenerateBands="False" onrowislandspopulating="whgridShowMessages_RowIslandsPopulating" > <Columns> <ig:TemplateDataField Key="AdiSoyadi"> <Header Text="Gönderen"> </Header> <ItemTemplate > <asp:Label CssClass="selam" ID="lblRoom" runat="server" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "AdiSoyadi") %>'> </asp:Label> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="Tarih"> <Header Text="Tarih"> </Header> <ItemTemplate > <asp:Label CssClass="selam" ID="lblRoom" runat="server" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Tarih") %>'> </asp:Label> </ItemTemplate> </ig:TemplateDataField> </Columns> <Bands> <ig:Band Key="MessageContent" DataKeyFields="ID" DataMember="vMesaj" AutoGenerateColumns="False"> <Columns> <ig:TemplateDataField Key="Mesaj"> <header text="Mesaj" /> <itemtemplate> <asp:Label CssClass="selam" ID="lblRoom" runat="server" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Mesaj") %>'> </asp:Label> </itemtemplate> </ig:TemplateDataField> </Columns> </ig:Band> </Bands> </ig:WebHierarchicalDataGrid>
I've handled problem by formatting container grid's column's dataformatstring. Thanks for interesting.
Hi Kerem Kambur,
Is there anything else that I can help you with?
again our colleagues have answered a similar question, so you can use it as a source of knowledge:
Add Columns from code behind
The examples and knowledge base are related to WebDataGrid instead of WebHierarchicalDataGrid, but the approach is the same.
Please, let me know whether this helps you!
Hi Petko
I've solved the problem by changing relations. But now I have another problem. I have two container grids having my data. But I need to add templatefields to containers. I need to add asp Label as template because I've some html formatted texts. How can I do this ?
I was able to find again few posts in our forum that may helps you:
why does 'no child grid script descriptors are available' error come?
Getting 'no child grid script descriptors are available' error
Runtime Exception: No child grid script descriptors are available!
However I was not able to run your project because of the missing dependency - TBS.cls .
If links do not help you, please provide me this class or other sample that I can run.