I am using the Telerik.Web.UI version 2010.3.1317.40
Visual Studio 2010 premium. .NET 4.0
I have a simple grid, embedded in a simple List View.
The data source for the list view is a Class Object.
When I get to the point that I am trying to get the list views key data value of customer number, it fails to set the parameter.
Let me post my code:
The error occurs in the Need Data source of the grid. When I try to set the parentiem, it is set to a value of null, or nothing.
I wind up with an error at the if(parentItem.DataItem == null) section of the code telling me that parentiem is null.
So, the code works for everything but this part, if I had code the intID to 0, and simply set the rg_Contacts.DataSource to mcAddressBooks[0].AddressBookContacts I get it to display, but simply with the 0 index of the class.
I would appreciate any help.
Visual Studio 2010 premium. .NET 4.0
I have a simple grid, embedded in a simple List View.
The data source for the list view is a Class Object.
When I get to the point that I am trying to get the list views key data value of customer number, it fails to set the parameter.
Let me post my code:
<%@ Page Language="c#" CodeBehind="AddressBook.aspx.cs" AutoEventWireup="True" EnableViewState="true" Inherits="JDE.Reporting.AddressBook" MasterPageFile="~/MenuMaster.Master" %> <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <asp:Content ID="WorkTracker" runat="server" ContentPlaceHolderID="MainPage"> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <h2> <asp:Label ID="lblReportHeader" runat="server"></asp:Label></h2> <p> <asp:Label ID="Label9" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="#3399FF"></asp:Label> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <telerik:RadSkinManager ID="RadSkinManager1" Runat="server" Skin="Windows7"> </telerik:RadSkinManager> </p> <telerik:RadListView ID="RLV_Address" runat="server" DataKeyNames="CustomerNumber" ItemPlaceholderID="Addresses" onneeddatasource = "RLV_Address_NeedDataSource"> <LayoutTemplate> <fieldset> <legend> Address </legend> <asp:PlaceHolder ID="Addresses" runat="server" /> </fieldset> </LayoutTemplate> <ItemTemplate> <legend> <p> Customer Number: <%#Eval("CustomerNumber")%> </p><p>Customer Name : <%# Eval("CustomerName") %> </p> <p>Customer Type : <%# Eval("CustomerType") %> </p></legend> <telerik:RadGrid ID="rgContacts" runat="server" AllowFilteringByColumn="False" AllowPaging="False" AllowSorting="false" ClientSettings-AllowColumnHide="false" AutoGenerateColumns="False" ShowGroupPanel="false" ShowFooter="true" EnableHeaderContextMenu="false" OnNeedDataSource="RG_Contacts_NeedDataSource"> <MasterTableView CommandItemDisplay="None"> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="CustomerNumber" HeaderText="CustomerNumber" UniqueName="CustomerNumber"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FullName" HeaderText="FullName" UniqueName="FullName"> </telerik:GridBoundColumn> </Columns> <NoRecordsTemplate> <asp:Label ID="lblNoTotalsRecords" runat="server" CssClass="LabelBold" Text="No records for the filtering selections you have chosen."></asp:Label> </NoRecordsTemplate> </MasterTableView> </telerik:RadGrid> </ItemTemplate> <ItemSeparatorTemplate> <span style="color: Blue; font-weight: bold;"> :: </span> </ItemSeparatorTemplate> </telerik:RadListView> <asp:PlaceHolder ID="Addresses" runat="server"></asp:PlaceHolder> </asp:Content> using System; using System.Collections; using System.ComponentModel; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Telerik.Web.UI; using System.Net.Mail; using System.Collections.Generic; using System.Text; using JDEReporting.Code; using Marlin.Utilities; using System.Reflection; namespace JDE.Reporting { // Remember to change the name of the class here to be the same value as is used // in the inherit on the .aspx page. public partial class AddressBook : System.Web.UI.Page { // protected System.Web.UI.WebControls.Label lblTable; Marlin.JDE.AddressBook.cAddressBooks mcAddressBooks; protected void Page_Load(object sender, System.EventArgs e) { this.MaintainScrollPositionOnPostBack = true; if (!IsPostBack) { // Get the name of the routine we are currently running. MethodBase lmth = MethodBase.GetCurrentMethod(); string lsRoutineName = lmth.DeclaringType + "." + lmth.Name; string lsReportName = MiscDBFuncs.GetReportTitle(Request.Url.Segments[Request.Url.Segments.Length - 1]); lblReportHeader.Text = lsReportName; Page.Title = lsReportName; mcAddressBooks = new Marlin.JDE.AddressBook.cAddressBooks(345183, Session["UserName"].ToString().Trim()); } } protected void RLV_Address_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e) { RLV_Address.DataSource = mcAddressBooks; } void RLV_Address_Item_ItemDataBound(object sender, RadListViewItemEventArgs e) { if (e.Item is RadListViewDataItem) { var grid = (RadGrid)e.Item.FindControl("RG_Contacts"); grid.Rebind(); } } protected void RG_Contacts_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { var parentItem = RLV_Address.NamingContainer as RadListViewDataItem; if (parentItem.DataItem == null) return; int intID = (int)parentItem.GetDataKeyValue("CustomerNumber"); RadGrid rg_Contacts = (RadGrid)source; rg_Contacts.DataSource = mcAddressBooks[intID].AddressBookContacts; } The error occurs in the Need Data source of the grid. When I try to set the parentiem, it is set to a value of null, or nothing.
I wind up with an error at the if(parentItem.DataItem == null) section of the code telling me that parentiem is null.
So, the code works for everything but this part, if I had code the intID to 0, and simply set the rg_Contacts.DataSource to mcAddressBooks[0].AddressBookContacts I get it to display, but simply with the 0 index of the class.
I would appreciate any help.