Using Datarow, how do I get the data out of each

Discussion in 'ASP .Net Datagrid Control' started by Dave, Feb 12, 2004.

  1. Dave

    Dave Guest

    column in the current row? For example, I have a datagrid
    filled up with a database and the user clicks on the edit
    button. I want to go to another page and edit this row.
    How do I get the data from this row? I dont want to get
    the data from the grid row, but the current row of my
    dataset. Please help! Thanks.
    Dave
     
    Dave, Feb 12, 2004
    #1
    1. Advertising

  2. Hi Dave,
    You can get the data from a datarow,
    If dr is the datarow,
    dr["columname"] will give you the value of the column in the
    datarow or if you know
    the index you can use dr[index])(index can be starting from 0,1,2,.....).
    If you want to iterate through each row in the datarowcollection
    in the datatable in the dataset,
    If ds is the dataset,

    foreach(DataRow dr in ds.Tables[0].Rows)

    {

    access each column value here like the way I described above.

    }

    Hope this helps.

    Marshal Antony

    ..NET Developer

    http://www.dotnetmarshal.com






    "Dave" <> wrote in message
    news:f2d701c3f12f$167e2ab0$...
    > column in the current row? For example, I have a datagrid
    > filled up with a database and the user clicks on the edit
    > button. I want to go to another page and edit this row.
    > How do I get the data from this row? I dont want to get
    > the data from the grid row, but the current row of my
    > dataset. Please help! Thanks.
    > Dave
     
    Marshal Antony, Feb 13, 2004
    #2
    1. Advertising

  3. Hi Marshal. Thanks for the reply.. I did this and it works!

    DataTable dt = ds.Tables[0];
    DataRow[] dr = dt.Select();
    textFIRST.Text = dr[0]["FNAME"].ToString();
    textLAST.Text = dr[0]["LNAME"].ToString();
    textPHONE.Text = dr[0]["PHONE_NUMB"].ToString();

    Thanks.
    Dave



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Dave Tessitore, Feb 13, 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. Chet
    Replies:
    3
    Views:
    150,682
  2. =?Utf-8?B?YXNhZA==?=

    showing data using DataRow

    =?Utf-8?B?YXNhZA==?=, Oct 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,071
    Grant Merwitz
    Oct 13, 2005
  3. Matt C.
    Replies:
    0
    Views:
    1,119
    Matt C.
    Jun 23, 2006
  4. orenl
    Replies:
    1
    Views:
    653
    Eliyahu Goldin
    Dec 4, 2006
  5. xzzy

    how to get value of datarow column on ItemDataBound

    xzzy, Jun 18, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    402
    Bhuva
    Jun 19, 2006
Loading...

Share This Page