|
Rank: Member Groups: Member
Joined: 5/3/2010 Posts: 11
|
Hi there, I have downloaded the trial version of the controls and as well as your demo.mdb database. Here is my code behind for trying to populate the Cars table from this demo.mdb into the Grid. The problem is that nothing is populated into the Grid. Could you please kindly provide some insight to this issue? Thanks a lot!
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Users/lfu.CORP/Documents/Visual Studio 2008/Projects/CustomGridTestPage/CustomGridTestPage/App_Data/demo.mdb"; OleDbConnection myConnection = new OleDbConnection(connectionString); DataTable dt;
using (myConnection) { myConnection.Open();
OleDbCommand myCommand = new OleDbCommand("select * from Cars", myConnection); OleDbDataAdapter oDA = new OleDbDataAdapter(myCommand); dt = new DataTable(); oDA.Fill(dt);
} Grid1.DataSource = dt.DefaultView; Grid1.DataBind(); } }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Make sure you have explicitly defined all the columns. Our Grid does not automatically create columns from your data source. You can find more information about how to define Grid columns here: http://doc.essentialobjects.com/library/1/grid/columns.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 5/3/2010 Posts: 11
|
Hi, thanks for your response! I have read over your documentation on Defining Columns, as well as all the steps in Getting Started: - Still no data shows up in the grid. -The only thing i noticed is that the Grid had 195 rows. -I do not need any editing functionality in the grid, so from the Property Window "Column" i chose Static Column. -Do i need to define anything for the StaticColumn property? -Do i still need to define Column Templates even if i dont need any textbox or checkbox or edit or delete functionality? I guess i'm still not too sure what you mean by explicitly "define the column". -can you please provide a brief/short example? - i am now using Linq and my own sql database for the data source. Here is the code for the code behind. What am i missing now? Much appreciated!
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { List<AreaLeadDistribution> ald; using (PSRI3Entities ent = new PSRI3Entities()) { ald = (from a in ent.AreaLeadDistribution select a).ToList<AreaLeadDistribution>(); }
Grid1.DataSource = ald; Grid1.DataBind(); } }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You need define columns and also set each column's DataField property.
Thanks
|
|