I am having the problems while binding the UltraWebGrid with WebHierarchicalDataSource. I have two ObjectDataSource returns list object. I am not able to bind. I am geting the "Object reference not set to an instance of an object." error.
I tried with SqlDataSource its working fine. Is it WebHierarchicalDataSource supports only SqlDataSourc.
Please help out this.
Here my code:
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" DataSourceID="WebHierarchicalDataSource1"> <Bands> <%-- BaseTableName and DataKeyField must both be specified to enable CRUD operations --%> <igtbl:UltraGridBand DataKeyField="PKTicketID"> <AddNewRow Visible="NotSet" View="NotSet"> </AddNewRow> <Columns> <igtbl:UltraGridColumn BaseColumnName="PKTicketID" DataType="System.Int64" IsBound="True" Key="PKTicketID"> <Header Caption="PKTicketID"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> </Columns> </igtbl:UltraGridBand> <igtbl:UltraGridBand DataKeyField="PKTicketID"> <AddNewRow Visible="NotSet" View="NotSet"> </AddNewRow> <Columns> <igtbl:UltraGridColumn BaseColumnName="PKTicketID" DataType="System.Int64" IsBound="True" Key="PKTicketID"> <Header Caption="PKTicketID"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="tickettitle" DataType="System.Int64" IsBound="True" Key="tickettitle"> <Header Caption="tickettitle"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> </Columns> </igtbl:UltraGridBand> </Bands> <DisplayLayout CompactRendering="False" AllowColSizingDefault="Free" AllowDeleteDefault="Yes" AutoGenerateColumns="false" AllowSortingDefault="Yes" AllowUpdateDefault="Yes" BorderCollapseDefault="Separate" HeaderClickActionDefault="SortMulti" Name="wgTicket" RowHeightDefault="20px" RowSelectorsDefault="No" SelectTypeRowDefault="Extended" SelectTypeCellDefault="Extended" Version="4.00" ViewType="Hierarchical" AllowColumnMovingDefault="OnClient" ScrollBarView="Horizontal" CellClickActionDefault="RowSelect" GridLinesDefault="None" HeaderTitleModeDefault="OnOverflow" TabDirection="BottomToTop" StationaryMargins="Header"> <RowStyleDefault CssClass="normal" Width="100%"> </RowStyleDefault> <RowAlternateStyleDefault CssClass="alternate"> </RowAlternateStyleDefault> <GroupByBox BoxStyle-BackColor="#FFFFC0" BoxStyle-HorizontalAlign="Center" BoxStyle-Height="10px"> </GroupByBox> <SelectedRowStyleDefault BackColor="LightGoldenrodYellow" ForeColor="Black" HorizontalAlign="Left" VerticalAlign="Middle"> </SelectedRowStyleDefault> <HeaderStyleDefault CssClass="iheader"> </HeaderStyleDefault> <FrameStyle Width="100%"> </FrameStyle> </DisplayLayout> </igtbl:UltraWebGrid>
<ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server"> <DataRelations> <ig:DataRelation ChildColumns="fkrelatedticketid" ChildDataViewID="SqlDataSource2_DefaultView" ParentColumns="Pkticketid" ParentDataViewID="SqlDataSource1_DefaultView" /> </DataRelations> <DataViews> <ig:DataView ID="SqlDataSource1_DefaultView" DataMember="DefaultView" DataSourceID="odsTicket" /> <ig:DataView ID="SqlDataSource2_DefaultView" DataMember="DefaultView" DataSourceID="odsRelated" /> </DataViews> </ig:WebHierarchicalDataSource>
<asp:ObjectDataSource ID="odsTicket" runat="server" SelectMethod="GetAllPoolTicket" SortParameterName="SortExpression" TypeName="A1CRM.TicketBO"> </asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsRelated" runat="server" SelectMethod="GetAllRelatedTicketsInPopUp" TypeName="A1CRM.TicketBO" SortParameterName="SortExpression"> </asp:ObjectDataSource>
Yes I have changed it.This is my WebHierarchicalDataSource.
<ig:WebHierarchicalDataSource ID="whdsTicket" runat="server"> <DataRelations> <ig:DataRelation ChildColumns="FkRelatedTicketId" ChildDataViewID="Related_View" ParentColumns="PkTicketid" ParentDataViewID="Ticket_View" /> </DataRelations> <DataViews> <ig:DataView ID="Ticket_View" DataMember="DefaultView" DataSourceID="odsTicket" /> <ig:DataView ID="Related_View" DataMember="DefaultView" DataSourceID="ObjectDataSource1" /> </DataViews> </ig:WebHierarchicalDataSource>
Please check if you have typed correctly all column names (case sensitive). For example the foreign key column is FKRelatedTicketId in your business object but is lower case in the DataRelation definition:
<ig:DataRelation ChildColumns="fkrelatedticketid" ChildDataViewID="SqlDataSource2_DefaultView" ParentColumns="Pkticketid" ParentDataViewID="SqlDataSource1_DefaultView" />
I am returning the List<TicketBO> instead of IEnumerable and my parent datasources are like in screen shots.
below datasets are sample Datasouce out puts.
Parent datasouce
PKTicketId TicketTitle FKRelatedTicketId TicketDescription4345 tt1 Null td1 4451 tt2 Null td2
4697 tt3l Null td3
4910 tt4 Null td4
child datasource
PKTicketId TicketTitle FKRelatedTicketId TicketDescription4403 tt 4345 td4449 tt 4451 4450 tt 4451 4709 tt 4697 4710 tt 4697 4911 tt 4910 4912 tt 4910
That's strange, it works fine on my test project. Are you sure that your TicketBO object returns correctly related (child) records?
Here is my sample code:
public class TicketBO{ public long PKTicketID { get; set; } public string tickettitle { get; set; } public long fkrelatedticketid { get; set; }
public IEnumerable GetAllPoolTicket() { List<TicketBO> list = new List<TicketBO>(); for (long i = 1; i < 6; i++) { list.Add(new TicketBO { PKTicketID = i, tickettitle = "Title" + i }); } return list; }
public IEnumerable GetAllRelatedTicketsInPopUp() { List<TicketBO> list = new List<TicketBO>(); for (long i = 1; i < 6; i++) { for (long j = 1; j < 3; j++) { list.Add( new TicketBO { PKTicketID = i * 10 + j, tickettitle = "Title " + j, fkrelatedticketid = i }); } } return list; }}
Thanks man its workig but it is not showing the "+" and child rows.