Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends. Look At below code(this is a windows form c# code):
DataSet ds = new DataSet();
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=localhost;initial catalog=univ;integrated security=true");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select name from students", con);
da.Fill(ds, "students");
label1.DataBindings.Add(new Binding("Text", ds, "students.name"));
con.Close();
}


Now i want this code on asp.net. But "label1.DataBindings" not suppord on asp.net.
My problem is: I want to show Last field from sql in label.text on ASP.net.

Thanks for your answer:thumbsup:
Posted
Updated 12-Dec-10 6:59am
v2

This is not possible in ASP.NET. You need to make a call to DB and get the required value from it. Then assign the value to the Text property of Label
 
Share this answer
 
Use the following to bind the label

label1.Text=ds.Tables[0].Rows[0]["name"].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900