This is a migrated thread and some comments may be shown as answers.

Bind Multiple Same-Level DetailTables Programmatically

6 Answers 181 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 25 Mar 2010, 09:29 PM
Hello, 
  I have a project in which have two DetailTables at the same level which need to be binded programatically at the same time. I have tried the example for binding DetailTables programmatically, however it only allows me to set one datasource property so the example does not work in this instace. I have been unable to find any examples of this, nor have I been able to figure it out by combining the "Multiple DetailTables at the Same-Level" example with the "Bind Hierarchy Programmatically" example. Any help would be greatly appreciated.

<telerik:RadGrid ID="rg_Report" runat="server" 
AutoGenerateColumns="false" 
PageSize="25" 
AllowPaging="true" 
OnDataBinding="rg_Report_DataBinding"   
onitemcommand="rg_Report_ItemCommand" 
ondetailtabledatabind="rg_Report_DetailTableDataBind"   
> 
<PagerStyle Mode="NumericPages" /> 
<MasterTableView DataKeyNames="PackageId">  
    <DetailTables> 
        <telerik:GridTableView DataKeyNames="package_id" Name="PackageNotes" Width="100%">  
            <Columns> 
                <telerik:GridBoundColumn UniqueName="Notes" DataField="notes" HeaderText="Notes">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="ShipNotes" DataField="shipnotes" HeaderText="Ship Notes">  
                </telerik:GridBoundColumn> 
            </Columns> 
        </telerik:GridTableView> 
        <telerik:GridTableView DataKeyNames="package_id" Name="TrackingScans" Width="100%">  
            <Columns> 
                <telerik:GridBoundColumn UniqueName="ScanDesc" DataField="scandesc" HeaderText="Scan Description">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn UniqueName="Location" DataField="location" HeaderText="Location">  
                </telerik:GridBoundColumn> 
                <telerik:GridDateTimeColumn UniqueName="DateTime" DataField="date_time" HeaderText="Date">  
                </telerik:GridDateTimeColumn> 
                <telerik:GridBoundColumn UniqueName="Notes" DataField="notes" HeaderText="Notes">  
                </telerik:GridBoundColumn> 
            </Columns> 
        </telerik:GridTableView> 
    </DetailTables>                          
    <Columns> 
        <telerik:GridBoundColumn UniqueName="PackageId" DataField="PackageId" HeaderText="Package ID" 
            ConvertEmptyStringToNull="true">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="Recipient" DataField="Recipient" HeaderText="Recipient">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="Location" DataField="location" HeaderText="Location">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="Room" DataField="room" HeaderText="Room/Cube">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="Sender" DataField="Sender" HeaderText="Sender">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="Carrier" DataField="Carrier" HeaderText="Carrier">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="TrackingNumber" DataField="TrackingNumber" HeaderText="Tracking #">  
        </telerik:GridBoundColumn> 
        <telerik:GridDateTimeColumn UniqueName="DateReceived" DataField="DateReceived" HeaderText="Date Received">  
        </telerik:GridDateTimeColumn> 
    </Columns> 
</MasterTableView> 
 

    protected void rg_Report_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)  
    {  
        GridDataItem dataItem = e.DetailTableView.ParentItem;  
 
        string spackageId = dataItem["PackageId"].Text.Replace("&nbsp;""");  
 
        if (!String.IsNullOrEmpty(spackageId.Trim()))  
        {  
            packageId = Convert.ToInt32(spackageId);  
        }  
 
        if (packageId != null)  
        {  
            switch (e.DetailTableView.Name)  
            {  
                case "PackageNotes":  
                    {  
                        e.DetailTableView.DataSource = reportProcs.GetPackageNotes(packageId);  
 
                        break;  
                    }  
                case "TrackingScans":  
                    {  
                        e.DetailTableView.DataSource = reportProcs.GetTrackingScans(packageId);  
 
                        break;  
                    }  
            }  
        }  
        else 
        {  
            e.DetailTableView.DataSource = null;  
        }  
    }  
 

6 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 29 Mar 2010, 02:47 PM
Hello Steve,

This behavior is not expected - you should be able to bind as many tables as you like in the DetailDataBind event. Could you paste your whole code behind (it is especially important to see how you are binding the grid and handling the ItemCommand event).


Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Steve
Top achievements
Rank 1
answered on 29 Mar 2010, 04:06 PM
I was able to figure it out. The problem dealt with a SQL Command object. Once that was fixed the grid behaved as expected. Thanks!
0
Nathan
Top achievements
Rank 1
answered on 30 Nov 2010, 10:26 PM
Hi,
Is it possible to bind and Olap Cube with telerik radGrid? if there is any please let me know?
0
Nathan
Top achievements
Rank 1
answered on 30 Nov 2010, 10:27 PM
Steve,
Is it possible to bind and Olap Cube with telerik radGrid? if there is any please let me know?
0
Sebastian
Telerik team
answered on 06 Dec 2010, 09:39 AM
Hi Nathan,

See my reply in this forum thread.

Best regards,
Sebastian
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Mukul
Top achievements
Rank 1
answered on 20 Apr 2012, 01:24 PM
hi Steve
I'm having same problem i bind it like this
in aspx.cs file

protected

void radGCustDetails_OnDetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)

 

{


string

strdate = objCommFun.GetTodaysDate();

 

 

string strBranchid = objSession.BranchID.ToString();

 

 

string[] arr = strdate.Split('-');

 

 

string day = arr[0];

 

 

string month = arr[1];

 

 

string year = arr[2];

 

 

string strtblNAme = e.DetailTableView.Name;

 

 

string custcode = e.DetailTableView.ParentItem["Cust_Code"].Text;

 

 

DataSet dsSHR = new DataSet();

 

 

dsSHR = BusinessLayer.MemberDtl.SearchShareDtl(custcode, strBranchid, month, year);

 

e.DetailTableView.DataSource = dsSHR ;
}
Now with this i can bind only one detailstable
what i have to do to bind other tables at same level.
Plz help me
Thanks in advance

Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Steve
Top achievements
Rank 1
Nathan
Top achievements
Rank 1
Sebastian
Telerik team
Mukul
Top achievements
Rank 1
Share this question
or