all groups > asp.net webcontrols > january 2004 >
You're in the

asp.net webcontrols

group:

Datagrid GUID column - KB 313155 doesn't work


Datagrid GUID column - KB 313155 doesn't work Brian Newtz
1/30/2004 8:31:10 AM
asp.net webcontrols:
Hello!

I have a slight problem. I'm making a dynamic database query engine with ASP.NET. I have a datagrid that must auto generate the columns (since it can bind to any column), and my database contains GUID columns. When I try to databind the datagrid to a table containing a GUID column (that the user picked to show), the GUID column is not shown. According to KB Article 313155, this behavior is by design.

However, the method shown in the article to work around the problem does not seem to work (Method 1). I've tried placing their code snippet in 3 spots:

1. before setting the datagrid's datasource property
2. after setting the datagrid's datasource property
3. after calling datagrid.databind (which this one shouldn't work, but I tried anyways).

All three attempts don't work. I always get the same error if the only columns returned are guid columns (if there are other 'normal' columns, the normal columns get generated and I don't get an error - the guid column is missing however):

"DataGrid with id 'dgResults' could not automatically generate any columns from the selected data source."

The error occurs on the dgResults.DataBind() statement.

My code is as follows (the conn.GetTableData method builds a select command from the columns (string[] parameter) from the specified table and database, and executes the command, returning a datatable with the data):

[start code]
DataTable t = conn.GetTableData(columns, ddlTables.SelectedValue, ddlDatabases.SelectedValue);

foreach(DataColumn c in t.Columns)
{
if (c.DataType == Type.GetType("System.Guid"))
{
BoundColumn bc = new BoundColumn();
bc.DataField = c.ColumnName;
bc.HeaderText = c.ColumnName;
dgResults.Columns.Add(bc);
}
}

dgResults.DataSource = t;
dgResults.DataBind();
[end code]

I have verified that the bound columns are, in fact, getting created if there is a guid column by stepping through the code with the debugger.

Any suggestions?
Thanks in advance,
-Brian
Re: Datagrid GUID column - KB 313155 doesn't work Brian Newtz
2/5/2004 2:37:16 PM
Anyone? I'd like to know if this can be resolved somehow...

Thanks,
Brian


[quoted text, click to view]
ASP.NET. I have a datagrid that must auto generate the columns (since it can
bind to any column), and my database contains GUID columns. When I try to
databind the datagrid to a table containing a GUID column (that the user
picked to show), the GUID column is not shown. According to KB Article
313155, this behavior is by design.
[quoted text, click to view]
not seem to work (Method 1). I've tried placing their code snippet in 3
spots:
[quoted text, click to view]
columns returned are guid columns (if there are other 'normal' columns, the
normal columns get generated and I don't get an error - the guid column is
missing however):
[quoted text, click to view]
command from the columns (string[] parameter) from the specified table and
database, and executes the command, returning a datatable with the data):
[quoted text, click to view]

Re: Datagrid GUID column - KB 313155 doesn't work Alvin Bruney [MVP]
2/5/2004 8:05:07 PM
Brian,
please use this link to have microsoft technical support help you further
trouble shoot this issue
https://webresponse.one.microsoft.com/oas/public/assistedintro.aspx

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
[quoted text, click to view]

AddThis Social Bookmark Button