Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use Datarow with DataTable to populate radiobuttonlist?
    text
    copied!<p>I created one quiz sample code, in that I have one <code>label</code> and one <code>RadioButtonList</code> for question and answer,</p> <pre><code> 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 &lt; 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; } </code></pre> <p>On Next button Click </p> <pre><code> protected void Button1_Click(object sender, EventArgs e) { LoadQuestion(); } protected void LoadQuestion() { if (Questions.Tables[0].Rows.Count&gt;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()); Question‌​s.Tables[0].Rows.Remove(DR); } } </code></pre> <p>What I want is, when user clicks on next button the next question with four option should display ,how should I get this using <code>datarow</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload