public void CreateTable() { tbl = new Table(); tbl.BorderColor = System.Drawing.Color.Black; PlaceHolder1.Controls.Add(tbl); TableRow tr = new TableRow(); tr.BackColor = System.Drawing.Color.Orange; tr.ID = "row0"; TableCell tc1 = new TableCell(); TableCell tc2 = new TableCell(); //creating lable System.Web.UI.WebControls.Label lable1 = new System.Web.UI.WebControls.Label(); System.Web.UI.WebControls.Label lable2 = new System.Web.UI.WebControls.Label(); lable1.Text = "Questions"; lable1.BackColor = System.Drawing.Color.Orange; lable2.Text = "Answers"; lable2.BackColor = System.Drawing.Color.Orange; // Add the control to the TableCell tc1.Controls.Add(lable1); tc2.Controls.Add(lable2); // Add the TableCell to the TableRow tr.Cells.Add(tc1); tr.Cells.Add(tc2); // Add the TableRow to the Table tbl.Rows.Add(tr); } public void AddRow(string s1,string[] s2) { TableRow tr = new TableRow(); tr.ID = "row" + Rows.ToString(); TableCell tc1 = new TableCell(); tc1.ID = "tc1" + Rows.ToString(); TableCell tc2 = new TableCell(); tc2.ID = "tc2" + Rows.ToString(); //creating dropdown list DropDownList ddl = new DropDownList(); ddl.ID = "list" + Rows.ToString(); ddl.Items.Add("Select Answer"); for (int i = 0; i < s2.Length; i++) { ddl.Items.Add(s2[i]); } ddl.SelectedIndexChanged += new EventHandler(dl_SelectedIndexChanged); ddl.AutoPostBack = true; ddl.EnableViewState = true; //creating lable System.Web.UI.WebControls.Label lable1 = new System.Web.UI.WebControls.Label(); lable1.Text = s1; lable1.ID = "lable" + Rows.ToString(); // Add the control to the TableCell tc1.Controls.Add(lable1); tc2.Controls.Add(ddl); // Add the TableCell to the TableRow tr.Cells.Add(tc1); tr.Cells.Add(tc2); // Add the TableRow to the Table tbl.Rows.Add(tr); } protected void dl_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddl9 = (DropDownList)sender; int quesid = 0; string questxt = ""; int ansid = 0; string anstxt = ddl9.SelectedItem.Text; DataRow[] dr = dt4.Select("anstxt='" + anstxt + "'"); foreach (DataRow row in dr) { quesid = Convert.ToInt32(row["quesid"]); ansid = Convert.ToInt32(row["ansid"]); questxt = row["questxt"].ToString(); //questxt=row[ } dt3.Rows.Add(quesid, questxt, ansid, anstxt); foreach (DataRow row in dt2.Rows) if (Convert.ToInt32(row["quesid"]) == quesid) row["son"] = "s"; //ListBox1.Items.Add("Ans: " + anstxt); //TextBox1.Text = ""; //DropDownList1.Items.Clear(); foreach (DataRow row in dt1.Rows) { if (Convert.ToInt32(row["ansid"]) == ansid) { row["status"] = 1; //MessageBox.Show("row status changed to" + row["status"].ToString()); } } ViewState["CECdt1"] = dt1; ViewState["CECdt3"] = dt3; int i = GetQuestion(dt1, dt2); GetAnswers(i); ViewState["CECtbl"] = PlaceHolder1; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)