Welcome Guest Search | Active Topics | Sign In | Register

Grid not populating Options
Brandyl Coffey
Posted: Wednesday, August 11, 2010 12:38:37 PM
Rank: Newbie
Groups: Member

Joined: 8/11/2010
Posts: 5
I am not sure what I am missing, but I can't seem to populate my grid:

Me.Grid1.DataSource = DAL.TransitLists.TransitListData.GetTransitLists
Grid1.DataBind()

In the DAL class:
Public Shared Function GetTransitLists() As DataTable
Dim strSql As String = " SELECT {0}.* FROM {0} "

strSql = String.Format(strSql, TABLE_NAME)

Dim dt As DataTable = SqlHelper.ExecuteDataset(Config.SqlServer.SQLDBCONN, CommandType.Text, strSql).Tables(0)
If dt Is Nothing Then Throw New ApplicationException(String.Format("Failed to return {0} records.", HUMAN_NAME))

dt.TableName = TABLE_NAME

Return dt



I am wondering if I haven't defined the columns properly? I just added a couple of static columns. Any ideas?
eo_support
Posted: Wednesday, August 11, 2010 12:46:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You want to check whether your DataTable has any items first by checking dt.Rows.Count property. If that value is greater than 0, then the Grid should have rows. If you don't see anything at all in the Grid, you should check your Columns. You MUST define all columns in our Grid as our Grid does not automatically generate columns.

Thanks!
Brandyl Coffey
Posted: Wednesday, August 11, 2010 2:36:13 PM
Rank: Newbie
Groups: Member

Joined: 8/11/2010
Posts: 5
Thanks for your reply. When I set a label to the row count, I get 156 rows:

Code: Visual Basic.NET
Me.LblRowCount.Text = DAL.TransitLists.TransitListData.GetTransitLists.Rows.Count.ToString


I looked at the documentation on defining the column, but didn't really help. How would I define the columns? I use the following code for my other datagrids:


Code: Visual Basic.NET
<asp:TemplateColumn HeaderText="VESSELS" SortExpression="VesselName">
                                        <ItemTemplate>
                                         <b><asp:Label ID="lblVesselName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.VesselName") %>'></asp:Label>
                                           </b><br> 
                                           <font size='-3' color='green'><asp:Label id="lblGuarantee" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.IsGuaranteed") %>'></asp:Label></font>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:DropDownList ID="ddlVessels" runat="server">
                                            </asp:DropDownList>
                                        </EditItemTemplate>
                                        <HeaderStyle Width="1.7in" />
                                    </asp:TemplateColumn>
Brandyl Coffey
Posted: Wednesday, August 11, 2010 2:58:33 PM
Rank: Newbie
Groups: Member

Joined: 8/11/2010
Posts: 5
This is what I have for the EO column definition:

<eo:StaticColumn HeaderText="Vessels" Name="VesselName">
</eo:StaticColumn>
eo_support
Posted: Wednesday, August 11, 2010 3:17:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You must set the column’s DataField proeprty. Otherwise it does not know where to get the data. You will not be able to use server side templates as you were using with standard ASP.NET Grid. Our Grid is very much a client side Grid so pretty much everything is done on the client side (that's why you can edit, scroll and page on the client side without posting back the page). The Grid supports a few simple column types (StaticColumn, TextBoxColumn, etc), I suggest you try those columns and get them working first. Once you get the basic idea of how our Grid works, if you still need complicated columns, you can use CustomColumn. It is explained in the documentation under "EO.Web Grid -> Custom Column" section, we also have several samples demonstrating how to use it in our sample project.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.