How to retrieve data from database onto asp table??
How to retrieve data from database onto asp(front end web page) table??
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.
Roei BarPosted Oct 6, 2009, 8:01 AM
Kirtan PatelPosted Oct 6, 2009, 7:24 AM
Here is Code I have written for it take a Look
dont forget to mark "Do you like answer" it will give me some credits :)
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand comm = new SqlCommand("Select * from Users", con);
SqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
TableRow r = new TableRow();
TableCell c1 = new TableCell();
TableCell c2 = new TableCell();
c1.Text = reader["Username"].ToString();
c2.Text = reader["Password"].ToString();
r.Cells.Add(c1);
r.Cells.Add(c2);
Table1.Rows.Add(r);
}
}
asif bashaPosted Oct 6, 2009, 6:40 AM
Kirtan PatelPosted Oct 6, 2009, 6:03 AM