[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Re: Datagrid GUID column - KB 313155 doesn't work

=?Utf-8?B?cm9kY2hhcg==?=

2/5/2004 7:37:00 PM

Anyone? I'd like to know if this can be resolved somehow...

Thanks,
Brian


"Brian Newtz" <anonymous@discussions.microsoft.com> wrote in message
news:CBCBFB11-BF78-41A7-8ABA-2399D336A721@microsoft.com...
> 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
>


1 Answer

Alvin Bruney

2/6/2004 2:05:00 AM

0

Brian,
please use this link to have microsoft technical support help you further
trouble shoot this issue
https://webresponse.one.microsoft.com/oas/public/assisted...

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl...
"Brian Newtz" <anonymous@discussions.microsoft.com> wrote in message
news:eESi59B7DHA.360@TK2MSFTNGP12.phx.gbl...
> Anyone? I'd like to know if this can be resolved somehow...
>
> Thanks,
> Brian
>
>
> "Brian Newtz" <anonymous@discussions.microsoft.com> wrote in message
> news:CBCBFB11-BF78-41A7-8ABA-2399D336A721@microsoft.com...
> > 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
> >
>
>