![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 | |
|
Senior Coder ![]() Join Date: Apr 2003
Location: Surrey, England
Posts: 1,179
Thanks: 5
Thanked 12 Times in 12 Posts
![]() |
Binary columns in a DataGrid bound to a DataReader
I am trying to use a System.Web.UI.WebControls.DataGrid with a SqlDataReader as the data source.
The DataReader may contain a wide variety of data so I do not know which columns I will need in advance. This all works well apart from for Binary data (such as a varbinary type in SQL Server 2005). It just skips these columns entirely. If I try to use just a binary column in the query, I get the following error: Quote:
__________________
My tech/code blog |
|
|
|
|
|
|
PM User | #2 |
|
Regular Coder ![]() Join Date: May 2007
Location: UK
Posts: 166
Thanks: 0
Thanked 18 Times in 18 Posts
![]() |
I see you are still using a DataGrid. Are you using an old version of ASP.NET? 1.0 or 1.1, perhaps?
The ObjectDataSource could be the answer to your problem but I think it was only introduced in ASP.NET 2.0. See http://quickstarts.asp.net/QuickStar...lang=VB+Source for an example of how to use an object data source with a GridView. The select method of the data source class executes SQL and puts the results into a DataTable. You can add code to transform columns or add columns, as required, before returning the results to the web page. (You can use AutoGenerateColumns="True" for your GridView if the user is allowed to make choices that affect the number or type of columns output to the web page.) |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|