G
Guest
Hi,
I’m having some troubles trying to bind my dataset to a GridView control
through an ObjectDataSource control. The binding works fine for regular
columns in my dataset, but I can’t seem to get my expression columns to show
up in my GridView. Anybody knows any neat tricks to make this work?
Here’s a “step-by-step†to reproduce my worries:
1. Create a new “ASP.NET web site†project
2. Add the “ASP.NET folder†called “App_Code†and add a dataset to this folder
3. Set up the datatable adapter to select some columns from e.g. the
Northwind Customers table, for instance the “CustomerIDâ€, “ContactNameâ€, and
“ContactTitle†columns.
4. Add a column to the dataset table and call it “ContactTitleNameâ€. Set the
“Expression†property to “ContactTitle + ' ' + ContactNameâ€.
5. Drag an ObjectDataSource control on to a web page
6. Set up the datasource to get data from your newly created dataset
tableadapter
7. Add a GridView control and set it’s datasource to your newly created
ObjectDataSource
8. Run the project
9. All columns except the expression column called “ContactTitleName†are
rendered
I’m having some troubles trying to bind my dataset to a GridView control
through an ObjectDataSource control. The binding works fine for regular
columns in my dataset, but I can’t seem to get my expression columns to show
up in my GridView. Anybody knows any neat tricks to make this work?
Here’s a “step-by-step†to reproduce my worries:
1. Create a new “ASP.NET web site†project
2. Add the “ASP.NET folder†called “App_Code†and add a dataset to this folder
3. Set up the datatable adapter to select some columns from e.g. the
Northwind Customers table, for instance the “CustomerIDâ€, “ContactNameâ€, and
“ContactTitle†columns.
4. Add a column to the dataset table and call it “ContactTitleNameâ€. Set the
“Expression†property to “ContactTitle + ' ' + ContactNameâ€.
5. Drag an ObjectDataSource control on to a web page
6. Set up the datasource to get data from your newly created dataset
tableadapter
7. Add a GridView control and set it’s datasource to your newly created
ObjectDataSource
8. Run the project
9. All columns except the expression column called “ContactTitleName†are
rendered