|
Rank: Newbie Groups: Member
Joined: 10/3/2009 Posts: 1
|
Hi everybody,
Please tell me how to populate the eo.webgrid. I programmatically create a datatable and bind it to the grid when application is running grid is not visible but asp gridview is working fine what is the main difference. I'm new to this controls please help me. Thanks in advance.
My code is like this:
<table> <tr> <td> <eo:Grid ID="gvw1" runat="server" AllowNewItem="true"> <Columns> <eo:RowNumberColumn HeaderText="SI No" /> </Columns> </eo:Grid> </td> <td> <asp:GridView ID="gvw" runat="server" AutoGenerateColumns="true" /> </td> </tr> </table>
code behind:
protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); DataTable dt = new DataTable(); DataColumn col1 = new DataColumn("First Name", typeof(string)); DataColumn col2 = new DataColumn("Full Name", typeof(string)); dt.Columns.Add(col1); dt.Columns.Add(col2);
DataRow dr1 = dt.NewRow(); dr1[0] = "Mike"; dr1[1] = "Taylor"; dt.Rows.Add(dr1); DataRow dr2 = dt.NewRow(); dr2[0] = "Neil"; dr2[1] = "Johnson"; dt.Rows.Add(dr2);
gvw.DataSource = dt; gvw.DataBind();
gvw1.DataSource = dt; gvw1.DataBind(); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You need to manually define all the columns. EO.Web Grid does not automatically create columns like ASP.NET GridView does. Please see here for more details: http://doc.essentialobjects.com/library/1/grid/start.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/10/2007 Posts: 5
|
I have the exact same problem. Please note that I did manually add the columns per documentation instructions but the data does not display. Interestingly enough, the number of rows do reflect the number of rows in the DataTable.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Farzad,
As long as you see rows, data binding should be working for you. If you still have problems, please post a complete test page that demonstrates the problem and we will be happy to take a look. Please make sure the test page runs and demonstrates the problem.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 8/10/2007 Posts: 5
|
I figured the problem! The issue was that I was setting the 'Name' property for the column whereas the control expects the 'Data Field' property to be set in accordance with the DataTable column definition.
|
|