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. Advertisements

  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



    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.
     
    Marshal Antony, Feb 12, 2004
    #2
    1. Advertisements

  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, Feb 12, 2004
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.