SqlConnection con = new SqlConnection(scon);
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select Question,Option1,Option2,Option3,Option4 from QuestionData", con);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataColumn dc in ds.Tables[0].Columns)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
Questionlable.Text = dr[0].ToString();
OptionList.Items[0].Text = dr[1].ToString();
OptionList.Items[1].Text = dr[2].ToString();
OptionList.Items[2].Text = dr[3].ToString();
OptionList.Items[3].Text = dr[4].ToString();
}
}
This is the code
I have table QuestionData with 5 column and 60 rows'
I am using this code in the button
I want to take my 1st column data in Questionlable.Text and and
2nd column data in the OptionList.Items[0].Text , like that
but here when i do this then i am getting last row value
not first row.
I want that when i click on button then it should be show all data one by one.
i am doing this ASP.NET web application.
I used the Sqldatareader also but same out .how can i get the frist column value one by one in the lable