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

Discussion in 'ASP .Net Web Controls' started by HelpPlease, Feb 11, 2004.

  1. HelpPlease

    HelpPlease Guest

    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,
     
    HelpPlease, Feb 11, 2004
    #1
    1. Advertising

  2. 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.dotnetmarshal.com



    "HelpPlease" <> wrote in message
    news:...
    > 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, Feb 12, 2004
    #2
    1. Advertising

  3. 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.dotnetmarshal.com



    Marshal Antony


    "Marshal Antony" <> wrote in message
    news:...
    > 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.dotnetmarshal.com
    >
    >
    >
    > "HelpPlease" <> wrote in message
    > news:...
    > > 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, Feb 12, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    3
    Views:
    596
  2. RSH
    Replies:
    2
    Views:
    2,295
  3. wardemon
    Replies:
    0
    Views:
    1,026
    wardemon
    Nov 30, 2006
  4. debiken
    Replies:
    1
    Views:
    420
    Mike Moore [MSFT]
    Nov 18, 2003
  5. bind a DataRow

    , Jan 5, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    152
Loading...

Share This Page