Hi,
I am new to ASP.NET.I wanted to know how can i get the the database column value from database to the label box which i wanted to be displayed after inserting the values.
Sita.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Muhammad IshaqPosted May 31, 2015, 6:43 AM
gagan sharmaPosted Jul 23, 2014, 4:18 AM
con.ConnectionString = ConfigurationManager.ConnectionStrings["CN"].ConnectionString;
string query = "select * from Product";
SqlDataAdapter adp = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
lblClient.Enabled = true;
lblClient1.Enabled = true;
lblClient2.Enabled = true;
lblClient3.Enabled = true;
lblClient.Text = ds.Tables[0].Rows[0].Field("P_Name");
lblClient1.Text = ds.Tables[0].Rows[1].Field("P_Name");
lblClient2.Text = ds.Tables[0].Rows[2].Field("P_Name");
lblClient3.Text = ds.Tables[0].Rows[3].Field("P_Name");
}
sita kPosted Mar 6, 2013, 4:03 PM
Gohil JayendrasinhPosted Feb 18, 2013, 1:12 AM
DataTable dt = new DataTable();
-- fill datatable
if (dt.Columns.Count > 0)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
if (dt.Columns[i].ColumnName != null)
{
string columnname = Convert.ToString(dt.Columns[i].ColumnName);
}
}
}
Dorababu MekaPosted Feb 18, 2013, 1:12 AM
SqlConnection con=new SqlConnection("urconnectionstring");
SqlCommand cmd=new SqlCommand("select query to retrieve the label value",con);
con.open();
SqlDataAdapter da=new SqlDataAdapter();
da.SelectCommand=cmd;
Dataset ds=new DataSet();
da.Fill(ds);
Label1.Text=ds.Tables[0].Rows[0]["Coulmnname"].ToString();