item bound error in hierarchy

2 posts, 1 answers
  1. Webster Velasco
    Webster Velasco avatar
    114 posts
    Member since:
    Jun 2012

    Posted 12 Mar 2010 Link to this post

    hi

    im having a poblem when i try to expand my childtable on my data grid..

    to be clear i have a prob on itemdatabound event


            If TypeOf e.Item Is GridDataItem Then 
                Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) 
                Dim DateDiff As Int32 = Convert.ToInt32(dataItem("colDTDIFF").Text) 
                If DateDiff <= 30 Then 
                    dataItem.BackColor = Drawing.Color.IndianRed 
                ElseIf DateDiff <= 60 Then 
                    dataItem.BackColor = Drawing.Color.Yellow 
                ElseIf DateDiff <= 90 Then 
                    dataItem.BackColor = Drawing.Color.SpringGreen 
                End If 
            End If 
        End Sub

    Dim DateDiff As Int32 = Convert.ToInt32(dataItem("colDTDIFF").Text) --> erro from this line


    here my aspx code:
                       <telerik:RadGrid ID="grdCrediti" DataSourceID="objDSScont" runat="server" Width="99.7%" 
                            AutoGenerateColumns="False" PageSize="15" AllowSorting="True" AllowPaging="True" ShowHeader="true" 
                            GridLines="None" ShowStatusBar="true" AllowAutomaticUpdates="true"
                            <PagerStyle Mode="NumericPages"></PagerStyle> 
                            <MasterTableView DataSourceID="objDSScont" AllowMultiColumnSorting="True" 
                                Width="100%" DataKeyNames="CODICE"
                                <Columns> 
                                    <telerik:GridBoundColumn SortExpression="DESCRIZIONE" HeaderText="Servizio" DataField="DESCRIZIONE" UniqueName="colDESCRIZIONE"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="DTORDINE" HeaderText="Data Ordine" DataField="DTORDINE" UniqueName="colDTORDINE"
                                    </telerik:GridBoundColumn>    
                                    <telerik:GridBoundColumn SortExpression="DTSCADENZA" HeaderText="Data Scadenza" DataField="DTSCADENZA" UniqueName="colDTSCADENZA"
                                    </telerik:GridBoundColumn>  
                                    <telerik:GridBoundColumn HeaderText="Giorni Residui" DataField="DTDIFF" UniqueName="colDTDIFF" AllowSorting="false"
                                    </telerik:GridBoundColumn>                                                                                       
                                </Columns> 
                                <DetailTables> 
                                    <telerik:GridTableView AutoGenerateColumns="false" Caption="Dettaglio Servizi" AllowSorting="false" 
                                        DataSourceID="objDETT" Width="100%" PageSize="7"
                                        <ParentTableRelation> 
                                            <telerik:GridRelationFields DetailKeyField="CODICE" MasterKeyField="CODICE" /> 
                                        </ParentTableRelation> 
                                        <PagerStyle AlwaysVisible="false" /> 
                                        <Columns> 
                                            <telerik:GridBoundColumn SortExpression="DESCRIZIONE" HeaderText="Descrizione" DataField="DESCRIZIONE" UniqueName="colDESCRIZIONE"
                                            </telerik:GridBoundColumn> 
                                            <telerik:GridBoundColumn SortExpression="QUANTITA" HeaderText="Ordinato" DataField="QUANTITA" UniqueName="colQUANTITA"
                                            </telerik:GridBoundColumn>    
                                            <telerik:GridBoundColumn SortExpression="QUANTITAINS" HeaderText="Utilizzato" DataField="QUANTITAINS" UniqueName="colQUANTITAINS"
                                            </telerik:GridBoundColumn>    
                                            <telerik:GridBoundColumn SortExpression="RESIDUO" HeaderText="Residuo" DataField="RESIDUO" UniqueName="colQUANTITAINS" AllowSorting="false"
                                            </telerik:GridBoundColumn>  
                                            <telerik:GridBoundColumn HeaderText="Giorni Residui" DataField="DTDIFF" UniqueName="colDTDIFF" visible="false"
                                            </telerik:GridBoundColumn>                                                                                                                            
                                        </Columns> 
                                    </telerik:GridTableView> 
                                </DetailTables>                             
                            </MasterTableView> 
                        </telerik:RadGrid> 

    need answer asap

    thanks

    regards
    webster



  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Mar 2010 Link to this post

    Hi,

    You can set the Name property for your detailtable of your grid. Then in the ItemDataBound event of the grid, you can check for the Name of the ownertableview and access the item accordingly:

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="RadGrid1_ItemDataBound">   
           <MasterTableView Name="Master" DataSourceID="SqlDataSource1">  
                  <DetailTables>  
                        <telerik:GridTableView DataSourceID="SqlDataSource2" Name="Detail" runat="server">                   

    c#:
     protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail"// to check for the detail table 
            { 
                GridDataItem childItem = (GridDataItem)e.Item; 
            } 
        } 

    Hope this helps..
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top