Showing posts with label How To get Column Value From DataSet. Show all posts
Showing posts with label How To get Column Value From DataSet. Show all posts

Monday, July 14, 2014

How To get Row Value And Column Value From DataSet

 if(ds.Tables[0].Rows[0][0].ToString()=="1")
        {
            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                if (ds.Tables[0].Rows[0][i].ToString() != "")
                {
                    Label l = new Label();
                    l.ID = "ll" + i;
                    l.Text =  "username"+ i;
                    form1.Controls.Add(l);

                }
           
            } 
        }

=============================================================================
string countryName = "USA";
        DataTable dt = new DataTable();
        int id = (from DataRow dr in dt.Rows
                  where (string)dr["CountryName"] == countryName
                  select (int)dr["id"]).FirstOrDefault();

=========================================================================================

query = "SELECT [EnrollmentNo] FROM [vw_NewAttenInfo]";
SqlDataAdapter adp = new SqlDataAdapter(query,con);
DataSet ds = new DataSet();
adp.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count;i++)
{
…………
…………
string st = ds.Tables[0].Rows[i]["EnrollmentNo"].ToString();
……
……
}

=======================================================================================