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

D

Dave

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
 
M

Marshal Antony

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
 
D

Dave Tessitore

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top