Telerik's radGrid & Drill Down feature

Posts   
 
    
Les
User
Posts: 13
Joined: 29-Aug-2007
# Posted on: 08-Oct-2007 21:54:40   

Hi All,

I am experimenting with how to get the "Drill Down" feature in Telerick's radGrid to work using the code generated. Using Northwind's Customer->Order relation.

I am using 2 LLBLGenProDataSource2 controls. I can drill down but the orders are not filtered on the CustomerID. i.e. all of the orders show up. I can do it fine using the ASP datasources but I am having a hard time with the LLBLGenProDataSource2 controls.

Should I use Prefetch Paths or a Session Parameter?

I have been spending an embarrassing amount time trying to figure this out. Any help would be apreciated. A working code example would be great. Is anyone having success using LLBLGen and Telerik controls?

Thanks in advance, Les

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 09-Oct-2007 04:16:47   

Hi Les,

You should be able to do that via LLBLGenProDataSource SelectParameters's (LLBLGenPro Help - Using generated code - Adapter - Databinding at design time and runtime - Databinding with ASP.NET 2.0 - Using the LLBLGenProDataSource2 control).

Could you post your declarative ASPX Telerik and LLBLGenProDataSource code?

David Elizondo | LLBLGen Support Team
Les
User
Posts: 13
Joined: 29-Aug-2007
# Posted on: 09-Oct-2007 20:24:43   

Daelmo, Thanks for your reply. Here are the HTML and event handlers:

1. Event Handlers first:

using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using NorthwindASP; using NorthwindASP.DatabaseSpecific; using NorthwindASP.EntityClasses; using NorthwindASP.FactoryClasses; using NorthwindASP.HelperClasses; using NorthwindASP.RelationClasses; using NorthwindASP.TypedViewClasses; using SD.LLBLGen.Pro.DQE.SqlServer; using Telerik.RadGridUtils; using Telerik.WebControls;

namespace AJAXEnabledWebApp { public partial class myStateManagement : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { lbxMessage.Items.Add("Time:" + DateTime.Now); lbxMessage.Items.Add("Session CustomerID:" + Session["CustomerID"]); lbxMessage.Items.Add("ViewState CustomerID:" + ViewState["CustomerID"]); }

    protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
    {
        lbxMessage.Items.Add("Doing Work:RadGrid1_DetailTableDataBind ");
        GridDataItem parentItem = e.DetailTableView.ParentItem;
        if (e.DetailTableView.DataSourceID == "dsOrder")
        {
            lbxMessage.Items.Add("CustomerId: " + parentItem["CustomerId"].Text);
            Session["CustomerId"] = parentItem["CustomerId"].Text;
            ViewState["CustomerId"] = parentItem["CustomerId"].Text;
        }
    }
}

}

2. HTML Next:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="myStateManagement.aspx.cs" Inherits="AJAXEnabledWebApp.myStateManagement" %>

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %> <%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses" TagPrefix="llblgenpro" %>

<!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>Untitled Page</title> </head>

<body> <form id="form1" runat="server"> <div> <aspsmile ropDownList ID="ddlCountry" runat="server" Style="z-index: 100; left: 0px; position: relative; top: 15px" Width="250px" AutoPostBack="True"> <asp:ListItem>USA</asp:ListItem> <asp:ListItem>UK</asp:ListItem> <asp:ListItem>Germany</asp:ListItem> </aspsmile ropDownList><br /> <asp:ListBox ID="lbxMessage" runat="server" Height="162px" Rows="12" Style="z-index: 101; left: 1px; position: relative; top: 16px" Width="550px"> </asp:ListBox> <radG:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AutoGenerateEditColumn="True" DataSourceID="dsCustomer" GridLines="None" Height="300px" Skin="WinXP" Style="z-index: 103; left: 11px; position: absolute; top: 287px" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" PageSize="20"> <ExportSettings> <Pdf PageBottomMargin="" PageFooterMargin="" PageHeaderMargin="" PageHeight="11in" PageLeftMargin="" PageRightMargin="" PageTopMargin="" PageWidth="8.5in" /> </ExportSettings> <MasterTableView AutoGenerateColumns="False" Caption="Customer" DataKeyNames="CustomerId" DataSourceID="dsCustomer" Name="Customer"> <ParentTableRelation> <radG:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" /> </ParentTableRelation> <Columns> <radG:GridBoundColumn DataField="CustomerId" HeaderText="CustomerId" ReadOnly="True" SortExpression="CustomerId" UniqueName="CustomerId"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" UniqueName="CompanyName"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" UniqueName="ContactName"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle" UniqueName="ContactTitle"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="Address" HeaderText="Address" SortExpression="Address" UniqueName="Address"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City" UniqueName="City"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="Region" HeaderText="Region" SortExpression="Region" UniqueName="Region"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="PostalCode" HeaderText="PostalCode" SortExpression="PostalCode" UniqueName="PostalCode"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country" UniqueName="Country"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="Phone" HeaderText="Phone" SortExpression="Phone" UniqueName="Phone"> </radG:GridBoundColumn> <radG:GridBoundColumn DataField="Fax" HeaderText="Fax" SortExpression="Fax" UniqueName="Fax"> </radG:GridBoundColumn> </Columns> <ExpandCollapseColumn Resizable="False"> <HeaderStyle Width="20px" /> </ExpandCollapseColumn> <DetailTables> <radG:GridTableView runat="server" DataKeyNames="OrderID" DataSourceID="dsOrder"> <ParentTableRelation> <radG:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" /> </ParentTableRelation> <ExpandCollapseColumn Resizable="False" Visible="False"> <HeaderStyle Width="20px" /> </ExpandCollapseColumn> <RowIndicatorColumn Visible="False"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> </radG:GridTableView> </DetailTables> <RowIndicatorColumn Visible="False"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> </MasterTableView> </radG:RadGrid> </div>    <llblgenpro:LLBLGenProDataSource2 ID="dsCustomer" runat="server" AdapterTypeName="NorthwindASP.DatabaseSpecific.DataAccessAdapter, NorthwindASPDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="NorthwindASP.FactoryClasses.CustomersEntityFactory, NorthwindASP"> <SelectParameters> <asp:ControlParameter ControlID="ddlCountry" Name="Country" PropertyName="SelectedValue" /> </SelectParameters> </llblgenpro:LLBLGenProDataSource2> <llblgenpro:LLBLGenProDataSource2 ID="dsOrder" runat="server" AdapterTypeName="NorthwindASP.DatabaseSpecific.DataAccessAdapter, NorthwindASPDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="NorthwindASP.FactoryClasses.OrdersEntityFactory, NorthwindASP"> <SelectParameters> <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="String" /> </SelectParameters> </llblgenpro:LLBLGenProDataSource2> </form> </body> </html>

=================== Thanks a bunch for the help........Les

Les
User
Posts: 13
Joined: 29-Aug-2007
# Posted on: 09-Oct-2007 20:26:52   

Daelmo, Much of the stuff above is that I am just displaying the Session Vars in a ListBox just so that I can tell what might be going on.

Thanks for your help, Les

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Oct-2007 12:12:13   

So are you updating the CustomerID session variable when a user drills down on a customer? Still not working with you?

I'm not sure how Telerik's radGrid works, but here is a wild guess:

            <ParentTableRelation>
                <radG:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
            </ParentTableRelation>

Fields are case sensetive, I would guess CustomerID should have been written as CustomerId. Same for OrderID.

Les
User
Posts: 13
Joined: 29-Aug-2007
# Posted on: 10-Oct-2007 22:33:49   

Walaa,

Sorry for the lapses in getting back with you but I have other projects that need my attention and it is difficult to be responsive. However, LLBLGen looks promising nd I do want to get it to working with Telerik. So please bear with me.

  1. I am trying to update sesssion's CustomerID var before I PerformSelect and then either set a relation or filter or something. Does that sound like I am on the right track?

  2. The Northwind database that I have has "CustomerID" as the case for the primary and foreign keys in the Customer and Order Tables.

Telerik is a popular controlset as is LLBLGen. LLBLGen would need to be compatible with it and vis-a-vis. Can you hook me up with someone who does have experience with their radGrid? I will be working on getting help from their end too. There has got to be a way to make this this stuff work together.

Thanks, Les

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-Oct-2007 11:17:49   

<ParentTableRelation> <radG:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" /> </ParentTableRelation> <Columns> <radG:GridBoundColumn DataField="CustomerId" HeaderText="CustomerId" ReadOnly="True" SortExpression="CustomerId" UniqueName="CustomerId">

Please look closely at the above code. The DataField in the Grid is defined with CustomerId while in the GridRelation it's CustomerID. I think LLBLGen would have generated the field as CustomerId. Please check the generated code. So regardeless of the field name in the database, you should stick to the names of the generated entityFields.

Les
User
Posts: 13
Joined: 29-Aug-2007
# Posted on: 12-Oct-2007 18:06:27   

Walaa,

Well thank you!!! Thank You! Thank You! Thank You!

You solved the problem. How obvious too. Maybe I can make some progress now. This is the first success that I have had! I have been messing wiith this problem for a month. (Well not full time) My spirits are lifted.

Les