DataGrid

J

johnpeter887

i have simple question. i am trying to view a table contents in a data
grid in a .aspx page, i can see the contents if i write the code in the
page load function.

But when i use the drag and drop approach Grid doesn't show anyting.
I drop a dataadapter on the web form connect it to the datasource,
write the select statement, then generate a dataset and then connect
this dataset to the DataGrid. I can see the column names in the
designer but nothing when i run it.

Any suggestions.
 
G

Guest

Is your code setting the DataSource property of the grid and then calling
it's DataBind method?
Peter
 
J

johnpeter887

This is what i am doing in my code and it works.......but doesn't work
when i don't write any code and just the follow the drag n drop
approach.

SqlConnection myConn = new SqlConnection("connection string");
SqlDataAdapter myAdap = new SqlDataAdapter("Query", myConn);
DataSet ds = new DataSet();
myAdap.Fill(ds, "TableName");
DataGrid1.DataSource=ds.Tables["TableName"];
DataGrid1.DataBind();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top