access datarow from a dataset

HI, I am a novice on datasets and would like to know how to acces the columns and each row clearly for teh dataset created by me. Please help

The dataset is ds_tablespecs

foreach (DataTable dt in ds_tablespecs.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
 
                    foreach (DataColumn dc in dt.Columns)
                    {
I nee d to access each datarow here 
 
 
                    }
                 }
        }

Open in new window

aspgeekAsked:
Who is Participating?
 
DhaestCommented:
foreach (DataTable table in ds_tablespecs.Tables)
                    {
                        foreach (DataRow row in table.Rows)
                        {                          
                               // Response.Write(row[col].ToString());
                                Label label1 = new Label();

                      label1.Text = row["COLUMN_NAME"].ToString();
                       }
                    }
0
 
DhaestCommented:
See also http://authors.aspalliance.com/aspxtreme/adonet/adonetprimer.aspx?pageno=8
foreach ( DataTable table in myData.Tables ) {
   foreach ( DataRow row in table.Rows ) {
      foreach ( DataColumn col in table.Columns ) {
         Response.Write ( row [ col ].ToString ( ) );
      }
   }
}
 
foreach table as DataTable in myData.Tables
   foreach row as DataRow in table.Rows
      foreach col as DataColumn in table.Columns
         Response.Write ( row ( col ).ToString ( ) ) 
      next
   next
next

Open in new window

0
 
aspgeekAuthor Commented:
Thanks for the response. I need to actually access it as datarows. How do i do it. I know we need to use datarows but I am having some trouble doing it
  foreach (DataTable table in ds_tablespecs.Tables)
                    {
                        foreach (DataRow row in table.Rows)
                        {                          
                               // Response.Write(row[col].ToString());
                                Label label1 = new Label();

                      label1.Text = ds_tablespecs.Tables[0].Rows[0]["COLUMN_NAME"].ToString();
                       }
                    }


I need to keep iterating the row as in to  the next one
ds_tablespecs.Tables[0].Rows[row]["COLUMN_NAME"].ToString();

instead of just having it as
ds_tablespecs.Tables[0].Rows[0]["COLUMN_NAME"].ToString();

I get two errors while trying to do this
The best overloaded match system.data.datarowcollection[int] has invalid arguments.
and
Argument 1 cannot convert from string to int

Please help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.