[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

Datarow can't bind to datagrid...I need a workaround

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

2/11/2004 3:36:00 PM

I am trying to bind a datarow() array to a datagrid and discovered that you can't. what do I use? I have multiple detail records for a master and the select method is returning a datarow() array that can't be bound to the grid.

I'm trying to use visual basic.net on a webform to do this. Any example would be appreciated.

thanks,
2 Answers

Marshal Antony

2/12/2004 5:56:00 AM

0

Hi,
You can create a datatable from the datatable(may be included in the
dataset) you have with structure only.
So declare a datatable,
DataTable dt=ds.Tables[0].Clone();// you can use your datatable to clone
Then your datarow collection


DataRow[] rows=whatever you do to select from the datatable;
Then iterate through the rows collection and import rows to the datatable
dt.
foreach(DataRow dr in rows)

{

dt.ImportRow(dr);

}


Then bind datatable dt to the datagrid.

Hope this helps.

Regards,

Marshal Antony

..NET developer

http://www.dotnetm...



"HelpPlease" <anonymous@discussions.microsoft.com> wrote in message
news:EF127FF6-FA62-4D74-9738-BBECC2836745@microsoft.com...
> I am trying to bind a datarow() array to a datagrid and discovered that
you can't. what do I use? I have multiple detail records for a master and
the select method is returning a datarow() array that can't be bound to the
grid.
>
> I'm trying to use visual basic.net on a webform to do this. Any example
would be appreciated.
>
> thanks,


Marshal Antony

2/12/2004 6:20:00 AM

0

You can easily convert C# code to VB.NET.
Sorry I forgot you need VB.NET.
For eg:
Dim dt as DataTable=Yourdatatable.Clone()
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetm...



Marshal Antony


"Marshal Antony" <dotnetmarshal@yahoo.com> wrote in message
news:OiHFdzS8DHA.3704@tk2msftngp13.phx.gbl...
> Hi,
> You can create a datatable from the datatable(may be included in the
> dataset) you have with structure only.
> So declare a datatable,
> DataTable dt=ds.Tables[0].Clone();// you can use your datatable to
clone
> Then your datarow collection
>
>
> DataRow[] rows=whatever you do to select from the datatable;
> Then iterate through the rows collection and import rows to the
datatable
> dt.
> foreach(DataRow dr in rows)
>
> {
>
> dt.ImportRow(dr);
>
> }
>
>
> Then bind datatable dt to the datagrid.
>
> Hope this helps.
>
> Regards,
>
> Marshal Antony
>
> .NET developer
>
> http://www.dotnetm...
>
>
>
> "HelpPlease" <anonymous@discussions.microsoft.com> wrote in message
> news:EF127FF6-FA62-4D74-9738-BBECC2836745@microsoft.com...
> > I am trying to bind a datarow() array to a datagrid and discovered that
> you can't. what do I use? I have multiple detail records for a master and
> the select method is returning a datarow() array that can't be bound to
the
> grid.
> >
> > I'm trying to use visual basic.net on a webform to do this. Any example
> would be appreciated.
> >
> > thanks,
>
>