I created one quiz sample code, in that I have one label
and one RadioButtonList
for question and answer,
public DataSet GetDataSet(string query)
{
DataSet QuestionSet = new DataSet();
DataTable QTable = new DataTable();
QTable.Columns.Add("ROW_NUMBER");
QTable.Columns.Add("QuestionNo");
QTable.Columns.Add("Tname");
QTable.Columns.Add("Tnumber");
QTable.Columns.Add("question");
QTable.Columns.Add("ans1");
QTable.Columns.Add("ans2");
QTable.Columns.Add("ans3");
QTable.Columns.Add("ans4");
DataRow dr;
for (int i = 0; i < 10; i++)
{
dr = QTable.NewRow();
dr[0] = i;
dr[1] = "Qno" + i;
dr[2] = "TST001";
dr[3] = "TST001";
//dr[4] = "Is n't so nice to have this test project in place ?";
dr[4] = "Question";
dr[5] = "Option1";
dr[6] = "Option2";
dr[7] = "Option3";
dr[8] = "Option45";
QTable.Rows.Add(dr);
}
QuestionSet.Tables.Add(QTable);
return QuestionSet;
}
On Next button Click
protected void Button1_Click(object sender, EventArgs e)
{
LoadQuestion();
}
protected void LoadQuestion()
{
if (Questions.Tables[0].Rows.Count>0)
{
DataRow DR = Questions.Tables[0].Rows[0]; Question.Text=DR[0].ToString()+" of "+totalQs; sno = DR[1].ToString();
Questionlbl.Text = DR[4].ToString();
rbtnAns.Items.Clear();rbtnAns.Items.Add(DR[5].ToString());
rbtnAns.Items.Add(DR[6].ToString());
rbtnAns.Items.Add(DR[7].ToString());
rbtnAns.Items.Add(DR[8].ToString());
Questions.Tables[0].Rows.Remove(DR);
}
}
What I want is, when user clicks on next button the next question with four option should display ,how should I get this using datarow
.
Yes see at follow I have added some sample code. you can try it. Put this code in your aspx page and configure the
datasource
as required.