Easy Question. Create a datagrid filled with data without any code on web page?

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I am using visual studio 2003. I user the server explorer and drag a table
onto a webform.

The program creates a "Connection" and an SQLDataAdapter Generates the
"Select, Insert, Delete" statments.

I right click on the SQLDataAdapter and chose Generate Dataset.

I drag a datagrid on to the form. Chose the SQLDataAdapter and dataset in
the properties.

I then run the webpage and I get nothing. When I do a preview on the
SQLDataAdapter I see the data in the table.

So what is my problem? Is there some documentation on how to use these
controls in this manner instead of alway writing code behind the scenes?

Thanks,

Rog
 
DataAdapter itself can not be a datasource of datagrid, you should use
fill method to build dataset or datatable. then use dataset's dataview
as a datasource of datagrid. hope it helps.
 
No matter what you do, drag and drop wise, you will have a couple of lines to
add:

this.sqlConnection1.Open();
this.sqlDataAdapter1.Fill(this.dataSet11);
Page.DataBind(); //Can also be DataGrid1.DataBind();

At least until the 2.0 Framework, where the SqlDataSource automatically does
this call.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Back
Top