﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><pubDate>Mon, 29 Mar 2010 09:58:10 GMT</pubDate><dc:creator>samtran0331</dc:creator><category>Object</category><category>binding</category><description>&lt;p&gt;Glenn,&lt;/p&gt;&lt;p&gt;Thank you for your help.&lt;/p&gt;
&lt;p&gt;Your example works fine.&lt;/p&gt;
&lt;p&gt;However, there is still something wrong within my class file...it binds perfectly well in all other data controls..but not WebGrid. &lt;/p&gt;
&lt;p&gt;I needed to move on so I just re-wrote the query and object so that it would work with Webgrid.&lt;/p&gt;
&lt;p&gt;Thanks for your help though!&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><pubDate>Thu, 18 Mar 2010 21:36:27 GMT</pubDate><dc:creator>Glayaar</dc:creator><category>Object</category><category>binding</category><description>Attached is the sample code ported to VB. Running the snippet you provided does not result in any issue in my environment. However, in the data generation, you did not insert the StructID and StructDesc property so the displayed column will be empty.&lt;br /&gt;&lt;br /&gt;Please see the attached sample for the lambda expression in assigned the property during creating a new instance&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&amp;nbsp; &amp;nbsp; 
</description></item><item><title>Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><pubDate>Thu, 18 Mar 2010 08:54:31 GMT</pubDate><dc:creator>samtran0331</dc:creator><category>Object</category><category>binding</category><description>&lt;p&gt;Thanks so much for your help Glenn.&lt;/p&gt;&lt;p&gt;Sorry to say that I'm working in VB.Net and while I can get your C# example to work, when I translate the code to VB.Net, it doesn't work.&lt;/p&gt;
&lt;p&gt;Both projects have the same references.  Both test pages have the same html/code on the aspx page.&lt;/p&gt;
&lt;p&gt;I'm inserting the VB codebehind, which should be an exact translation of your C# example, can you see what would make it not work??&lt;/p&gt;&lt;pre&gt;Imports System&lt;br /&gt;Imports System.Collections.Generic&lt;br /&gt;Imports System.Linq&lt;br /&gt;Imports System.Web&lt;br /&gt;Imports System.Web.UI&lt;br /&gt;Imports System.Web.UI.WebControls&lt;br /&gt;Imports System.Data&lt;br /&gt;&lt;br /&gt;Partial Public Class _Default&lt;br /&gt;    Inherits System.Web.UI.Page&lt;br /&gt;&lt;br /&gt;    Public dt As DataTable&lt;br /&gt;&lt;br /&gt;    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init&lt;br /&gt;        If dt Is Nothing Then&lt;br /&gt;            dt = New DataTable("Parent")&lt;br /&gt;            dt.Columns.Add("ID")&lt;br /&gt;            dt.Columns.Add("Name")&lt;br /&gt;            dt.Columns.Add("Author")&lt;br /&gt;            dt.Columns.Add("CustomObj", GetType([Object]))&lt;br /&gt;            dt.Rows.Add(New Object() {1, "B1", "A1", New CustomStruct()})&lt;br /&gt;            dt.Rows.Add(New Object() {2, "B2", "A2", New CustomStruct()})&lt;br /&gt;            dt.Rows.Add(New Object() {3, "B3", "A3", New CustomStruct()})&lt;br /&gt;            dt.Rows.Add(New Object() {4, "B4", "A4", New CustomStruct()})&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load&lt;br /&gt;        With Me.GridView1&lt;br /&gt;            .DataSource = Me.dt&lt;br /&gt;            .AutoGenerateColumns = False&lt;br /&gt;            .DataBind()&lt;br /&gt;        End With&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;    Protected Sub TestInitializeDataSource(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.DataSourceEventArgs)&lt;br /&gt;        e.DataSource = Me.dt&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;Public Class CustomStruct&lt;br /&gt;    Private _StructID As String&lt;br /&gt;    Public Property StructID() As String&lt;br /&gt;        Get&lt;br /&gt;            Return _StructID&lt;br /&gt;        End Get&lt;br /&gt;        Set(ByVal value As String)&lt;br /&gt;            _StructID = value&lt;br /&gt;        End Set&lt;br /&gt;    End Property&lt;br /&gt;&lt;br /&gt;    Private _StructDesc As String&lt;br /&gt;    Public Property StructDesc() As String&lt;br /&gt;        Get&lt;br /&gt;            Return _StructDesc&lt;br /&gt;        End Get&lt;br /&gt;        Set(ByVal value As String)&lt;br /&gt;            _StructDesc = value&lt;br /&gt;        End Set&lt;br /&gt;    End Property&lt;br /&gt;End Class&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><pubDate>Wed, 17 Mar 2010 23:25:32 GMT</pubDate><dc:creator>Glayaar</dc:creator><category>Object</category><category>binding</category><description>&lt;p&gt;In my test the template cell method works. Attached is the sample page I used to test the template cell.&lt;/p&gt;&lt;p&gt;I create a simple datatable with a column which hold a complex object which is bound to WebGrid and GridView. The data is shown correctly in both WebGrid and GridView. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I am already using the latest build of WebGrid 7 and WebUI Framework&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><pubDate>Wed, 17 Mar 2010 08:23:27 GMT</pubDate><dc:creator>samtran0331</dc:creator><category>Object</category><category>binding</category><description>&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(99, 36, 35);"&gt;Hi Glenn,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Thanks for the response, but I tried that already and got the error:&lt;/p&gt;
&lt;p&gt;&lt;span style="color: rgb(99, 36, 35);"&gt;&lt;strong&gt;&lt;em&gt;DataBinding: 'System.DBNull' does not contain a property with the name 'ETID'. &lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I've also tried brackets around the Eval like this:&lt;/p&gt;
&lt;p&gt;&amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Eval("[Sunday.ETID]") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt; &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;and get the error:&lt;/p&gt;
&lt;p&gt;&lt;span style="color: rgb(99, 36, 35);"&gt;&lt;strong&gt;&lt;em&gt;DataBinding: '[Sunday' is not a valid indexed expression.&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I've also tried this:&lt;/p&gt;
&lt;p&gt; &amp;lt;ISWebGrid:WebGridColumn Caption="Sun ETID" Name="SunETID" ColumnType="Template" DataMember="Sunday"&amp;gt;&lt;br /&gt; &amp;lt;CellTemplate&amp;gt;&lt;br /&gt; &amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Eval("ETID") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt; &amp;lt;/CellTemplate&amp;gt;&lt;br /&gt; &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Which returns the error:&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color: rgb(255, 255, 255); color: rgb(99, 36, 35);"&gt;&lt;strong&gt;&lt;em&gt;DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ETID'. &lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I'm inserting my test page as a code snippet...it includes a standard Gridview, a telerik RadGrid, and an Intersoft Webgrid...also note that I have a test page with nothing but the Webgrid and it still doesn't work.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;The Webgrid is the only control that won't bind to "Sunday.ETID"&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your help!&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;    &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;telerik:RadScriptManager ID="RadScriptManager1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;/telerik:RadScriptManager&amp;gt;&lt;br /&gt;    &amp;lt;asp:GridView ID="GridView1" runat="server"&amp;gt;&lt;br /&gt;        &amp;lt;Columns&amp;gt;&lt;br /&gt;            &amp;lt;asp:BoundField DataField="Client" HeaderText="Client" ReadOnly="True" SortExpression="Client" /&amp;gt;&lt;br /&gt;            &amp;lt;asp:BoundField DataField="JobDesc" HeaderText="Job" SortExpression="Job" /&amp;gt;&lt;br /&gt;            &amp;lt;asp:TemplateField HeaderText="Sun ETID"&amp;gt;&lt;br /&gt;                &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Eval("Sunday.ETID") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;            &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;        &amp;lt;/Columns&amp;gt;&lt;br /&gt;    &amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;    &amp;lt;br /&amp;gt;&lt;br /&gt;    &amp;lt;telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"&amp;gt;&lt;br /&gt;        &amp;lt;mastertableview&amp;gt;&lt;br /&gt;        &amp;lt;RowIndicatorColumn&amp;gt;&lt;br /&gt;        &amp;lt;HeaderStyle Width="20px"&amp;gt;&amp;lt;/HeaderStyle&amp;gt;&lt;br /&gt;        &amp;lt;/RowIndicatorColumn&amp;gt;&lt;br /&gt;        &amp;lt;ExpandCollapseColumn&amp;gt;&lt;br /&gt;        &amp;lt;HeaderStyle Width="20px"&amp;gt;&amp;lt;/HeaderStyle&amp;gt;&lt;br /&gt;        &amp;lt;/ExpandCollapseColumn&amp;gt;&lt;br /&gt;            &amp;lt;Columns&amp;gt;&lt;br /&gt;                &amp;lt;telerik:GridBoundColumn UniqueName="column1" DataField="Client" HeaderText="Client"&amp;gt;&lt;br /&gt;                &amp;lt;/telerik:GridBoundColumn&amp;gt;&lt;br /&gt;                &amp;lt;telerik:GridBoundColumn UniqueName="column2" DataField="JobDesc" HeaderText="Job"&amp;gt;&lt;br /&gt;                &amp;lt;/telerik:GridBoundColumn&amp;gt;&lt;br /&gt;                &amp;lt;telerik:GridBoundColumn UniqueName="column3" DataField="Sunday.ETID" HeaderText="Sun ETID"&amp;gt;&lt;br /&gt;                &amp;lt;/telerik:GridBoundColumn&amp;gt;&lt;br /&gt;            &amp;lt;/Columns&amp;gt;&lt;br /&gt;        &amp;lt;/mastertableview&amp;gt;&lt;br /&gt;    &amp;lt;/telerik:RadGrid&amp;gt;&lt;br /&gt;    &amp;lt;br /&amp;gt;&lt;br /&gt;    &amp;lt;ISWebGrid:WebGrid ID="WebGrid1" runat="server" UseDefaultStyle="True" Height="600px"&lt;br /&gt;        DefaultStyleMode="Elegant" Width="90%"&amp;gt;&lt;br /&gt;        &amp;lt;LayoutSettings AllowAddNew="Yes" AllowColumnFreezing="Yes" AllowColumnMove="No"&lt;br /&gt;            AllowDelete="Yes" AllowEdit="Yes" AllowExport="Yes" AllowFilter="No" AllowGrouping="No"&lt;br /&gt;            AllowMultipleSelection="Yes" AllowSelectColumns="Yes" AllowSorting="Yes" AutoFitColumns="True"&lt;br /&gt;            ShowRefreshButton="true" AutoWidth="True" ColumnFooters="No" GroupByBoxVisible="False"&lt;br /&gt;            AllowContextMenu="False"&amp;gt;&lt;br /&gt;        &amp;lt;/LayoutSettings&amp;gt;&lt;br /&gt;        &amp;lt;RootTable&amp;gt;&lt;br /&gt;            &amp;lt;Columns&amp;gt;&lt;br /&gt;                &amp;lt;ISWebGrid:WebGridColumn Name="WebGridColumn0" Width="100px" DataMember="Client"&amp;gt;&lt;br /&gt;                &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;&lt;br /&gt;                &amp;lt;ISWebGrid:WebGridColumn Name="WebGridColumn1" Width="100px" DataMember="JobDesc"&amp;gt;&lt;br /&gt;                &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;&lt;br /&gt;                &amp;lt;ISWebGrid:WebGridColumn Name="WebGridColumn2" Width="100px" DataMember="Sunday"&lt;br /&gt;                    ColumnType="Template"&amp;gt;&lt;br /&gt;                    &amp;lt;CellTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label1" runat="server" Text='Hello'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/CellTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;&lt;br /&gt;                &amp;lt;ISWebGrid:WebGridColumn Caption="Sun ETID" Name="SunETID" ColumnType="Template" DataMember="Sunday"&amp;gt;&lt;br /&gt;                    &amp;lt;CellTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Eval("ETID") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/CellTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;&lt;br /&gt;            &amp;lt;/Columns&amp;gt;&lt;br /&gt;        &amp;lt;/RootTable&amp;gt;&lt;br /&gt;    &amp;lt;/ISWebGrid:WebGrid&amp;gt;&lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><pubDate>Wed, 17 Mar 2010 04:24:30 GMT</pubDate><dc:creator>Glayaar</dc:creator><category>Object</category><category>binding</category><description>&lt;p&gt;You will need to use similar method with the Grid View.  You will need to use cell template in order to bind complex object property. Here is the snippet:&lt;/p&gt;&lt;pre&gt;&amp;lt;ISWebGrid:WebGridColumn Caption="Sun ETID" Name="SunETID" ColumnType="Template"&amp;gt;&lt;br /&gt;&amp;lt;CellTemplate&amp;gt;&lt;br /&gt;    &amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Eval("Sunday.ETID") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;&amp;lt;/CellTemplate&amp;gt;&lt;br /&gt;&amp;lt;/ISWebGrid:WebGridColumn&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Simple question on binding to complex object</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Simple-question-on-binding-to-complex-object/</link><pubDate>Tue, 16 Mar 2010 09:57:17 GMT</pubDate><dc:creator>samtran0331</dc:creator><category>Object</category><category>binding</category><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I'm trying to bind a complex object and can't figure out how to do it using WebGrid.&lt;/p&gt;
&lt;p&gt;With a normal ASP.Net GridView control, I can do this:&lt;/p&gt;
&lt;p&gt; &amp;lt;asp:TemplateField HeaderText="Sun ETID"&amp;gt;&lt;br /&gt; &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt; &amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Eval("&lt;strong&gt;Sunday.ETID&lt;/strong&gt;") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt; &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt; &amp;lt;/asp:TemplateField&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;With a Telerik RadGrid, I can do this:&lt;/p&gt;
&lt;p&gt; &amp;lt;telerik:GridBoundColumn UniqueName="column3" DataField="&lt;strong&gt;Sunday.ETID&lt;/strong&gt;" HeaderText="Sun ETID"&amp;gt;&lt;br /&gt; &amp;lt;/telerik:GridBoundColumn&amp;gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;My datasource is an object called "Timesheet" this is the datasource for the grids.&lt;/p&gt;
&lt;p&gt;Within the Timesheet object is another collection of objects for each day of the week.  &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;That is why I can bind to "Sunday.ETID"..."Sunday" is an object within "Timesheet"&lt;/p&gt;
&lt;p&gt;And "Sunday" has a property called "ETID".&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;What would be the syntax to bind a column using Intersoft WebGrid?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>