Datagrid Designer question
-
I've been playing around with a web application driven by an Access Database. I can programmatically connect to the database fill a dataset, bind the dataset to the datagrid, and everything works as expected. Here's my question... I thought I could do all that from the designer, so I commented out code that programmatically connects to the database loads the dataset, and binds to the Datagrid. Then made the same connections with the designer through the properties of the DataGrid. In the designer, I added a DataAdapter, and generated a Dataset from it. Then I set the DataGrid DataSource to the DataSet, and Set the DataMember to a table within the Dataset. In the PageLoad event handler, I added a call to DataBind(), but when I run the app, the DataGrid doesn't load! Am I trying to do too much with the designer?
-
I've been playing around with a web application driven by an Access Database. I can programmatically connect to the database fill a dataset, bind the dataset to the datagrid, and everything works as expected. Here's my question... I thought I could do all that from the designer, so I commented out code that programmatically connects to the database loads the dataset, and binds to the Datagrid. Then made the same connections with the designer through the properties of the DataGrid. In the designer, I added a DataAdapter, and generated a Dataset from it. Then I set the DataGrid DataSource to the DataSet, and Set the DataMember to a table within the Dataset. In the PageLoad event handler, I added a call to DataBind(), but when I run the app, the DataGrid doesn't load! Am I trying to do too much with the designer?
Personally, i loath doing any of that via the designer.... But regardless.... You said you databinded, but did you fill the dataset?
SqlDataAdapter1.Fill(Dataset1) Datagrid1.Databind()
-
Personally, i loath doing any of that via the designer.... But regardless.... You said you databinded, but did you fill the dataset?
SqlDataAdapter1.Fill(Dataset1) Datagrid1.Databind()
I'm just about at that point... It looks like I need to learn all the quirks of the designer, instead of doing something useful. I went back to my hard coded version, and will come back to the designer approach some day... Maybe!
-
I'm just about at that point... It looks like I need to learn all the quirks of the designer, instead of doing something useful. I went back to my hard coded version, and will come back to the designer approach some day... Maybe!
Either way it gets "Hard Coded" Just expand the Region of auto generated microsoft code and you'll see it.
-
I've been playing around with a web application driven by an Access Database. I can programmatically connect to the database fill a dataset, bind the dataset to the datagrid, and everything works as expected. Here's my question... I thought I could do all that from the designer, so I commented out code that programmatically connects to the database loads the dataset, and binds to the Datagrid. Then made the same connections with the designer through the properties of the DataGrid. In the designer, I added a DataAdapter, and generated a Dataset from it. Then I set the DataGrid DataSource to the DataSet, and Set the DataMember to a table within the Dataset. In the PageLoad event handler, I added a call to DataBind(), but when I run the app, the DataGrid doesn't load! Am I trying to do too much with the designer?
Hi there, As StylezHouse pointed out that you basically need to do two more things though you drag/drop data components from the Toolbox: + Fill data in the dataset. + Bind data to the grid calling the DataBind method (you've done that). This is a limitation in the ASP.NET 1.1. Though you have generated the dataset object from the adapter, the dataset is not automatically filled in with data, so you need to do that in code. Also, you need to call the DataBind method as the grid does not automatically display data in the specified datasource. A good news is that this issue is addressed in ASP.NET 2.0, you won't even place any code in the page, what you need to do is to drag/drop the gridview (the successor of the datagrid control) and the datasource control on the web page, and done!
-
Hi there, As StylezHouse pointed out that you basically need to do two more things though you drag/drop data components from the Toolbox: + Fill data in the dataset. + Bind data to the grid calling the DataBind method (you've done that). This is a limitation in the ASP.NET 1.1. Though you have generated the dataset object from the adapter, the dataset is not automatically filled in with data, so you need to do that in code. Also, you need to call the DataBind method as the grid does not automatically display data in the specified datasource. A good news is that this issue is addressed in ASP.NET 2.0, you won't even place any code in the page, what you need to do is to drag/drop the gridview (the successor of the datagrid control) and the datasource control on the web page, and done!
Thanks... I've added those two calls to my pages, and everything's working fine. Was just wondering if I was missing something.