iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Glenn,
Thank you for your help.
Your example works fine.
However, there is still something wrong within my class file...it binds perfectly well in all other data controls..but not WebGrid.
I needed to move on so I just re-wrote the query and object so that it would work with Webgrid.
Thanks for your help though!
Thanks so much for your help Glenn.
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.
Both projects have the same references. Both test pages have the same html/code on the aspx page.
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??
Imports SystemImports System.Collections.GenericImports System.LinqImports System.WebImports System.Web.UIImports System.Web.UI.WebControlsImports System.DataPartial Public Class _Default Inherits System.Web.UI.Page Public dt As DataTable Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init If dt Is Nothing Then dt = New DataTable("Parent") dt.Columns.Add("ID") dt.Columns.Add("Name") dt.Columns.Add("Author") dt.Columns.Add("CustomObj", GetType([Object])) dt.Rows.Add(New Object() {1, "B1", "A1", New CustomStruct()}) dt.Rows.Add(New Object() {2, "B2", "A2", New CustomStruct()}) dt.Rows.Add(New Object() {3, "B3", "A3", New CustomStruct()}) dt.Rows.Add(New Object() {4, "B4", "A4", New CustomStruct()}) End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load With Me.GridView1 .DataSource = Me.dt .AutoGenerateColumns = False .DataBind() End With End Sub Protected Sub TestInitializeDataSource(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.DataSourceEventArgs) e.DataSource = Me.dt End SubEnd ClassPublic Class CustomStruct Private _StructID As String Public Property StructID() As String Get Return _StructID End Get Set(ByVal value As String) _StructID = value End Set End Property Private _StructDesc As String Public Property StructDesc() As String Get Return _StructDesc End Get Set(ByVal value As String) _StructDesc = value End Set End PropertyEnd Class
Hi Glenn,
Thanks for the response, but I tried that already and got the error:
DataBinding: 'System.DBNull' does not contain a property with the name 'ETID'.
I've also tried brackets around the Eval like this:
<asp:Label ID="Label1" runat="server" Text='<%# Eval("[Sunday.ETID]") %>'></asp:Label>
and get the error:
DataBinding: '[Sunday' is not a valid indexed expression.
I've also tried this:
<ISWebGrid:WebGridColumn Caption="Sun ETID" Name="SunETID" ColumnType="Template" DataMember="Sunday"> <CellTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ETID") %>'></asp:Label> </CellTemplate> </ISWebGrid:WebGridColumn>
Which returns the error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ETID'.
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.
The Webgrid is the only control that won't bind to "Sunday.ETID"
Thanks for your help!
<form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <asp:GridView ID="GridView1" runat="server"> <Columns> <asp:BoundField DataField="Client" HeaderText="Client" ReadOnly="True" SortExpression="Client" /> <asp:BoundField DataField="JobDesc" HeaderText="Job" SortExpression="Job" /> <asp:TemplateField HeaderText="Sun ETID"> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("Sunday.ETID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <br /> <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"> <mastertableview> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn UniqueName="column1" DataField="Client" HeaderText="Client"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="column2" DataField="JobDesc" HeaderText="Job"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="column3" DataField="Sunday.ETID" HeaderText="Sun ETID"> </telerik:GridBoundColumn> </Columns> </mastertableview> </telerik:RadGrid> <br /> <ISWebGrid:WebGrid ID="WebGrid1" runat="server" UseDefaultStyle="True" Height="600px" DefaultStyleMode="Elegant" Width="90%"> <LayoutSettings AllowAddNew="Yes" AllowColumnFreezing="Yes" AllowColumnMove="No" AllowDelete="Yes" AllowEdit="Yes" AllowExport="Yes" AllowFilter="No" AllowGrouping="No" AllowMultipleSelection="Yes" AllowSelectColumns="Yes" AllowSorting="Yes" AutoFitColumns="True" ShowRefreshButton="true" AutoWidth="True" ColumnFooters="No" GroupByBoxVisible="False" AllowContextMenu="False"> </LayoutSettings> <RootTable> <Columns> <ISWebGrid:WebGridColumn Name="WebGridColumn0" Width="100px" DataMember="Client"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Name="WebGridColumn1" Width="100px" DataMember="JobDesc"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Name="WebGridColumn2" Width="100px" DataMember="Sunday" ColumnType="Template"> <CellTemplate> <asp:Label ID="Label1" runat="server" Text='Hello'></asp:Label> </CellTemplate> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Sun ETID" Name="SunETID" ColumnType="Template" DataMember="Sunday"> <CellTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ETID") %>'></asp:Label> </CellTemplate> </ISWebGrid:WebGridColumn> </Columns> </RootTable> </ISWebGrid:WebGrid> </form>
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname