Click here to Skip to main content
15,847,903 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
try
            {
                con_data.con.Open();
                string sql = "select * from t_qus_ans ";
                SqlCommand cmd = new SqlCommand(sql,con_data.con);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {                   
                            HtmlTableRow row = new HtmlTableRow();
                            HtmlTableRow row1 = new HtmlTableRow();
                            HtmlTableCell cel1 = new HtmlTableCell();
                            Label lblqus = new Label();                         
                            cel1.Controls.Add(lblqus);
                            Label label1 = new Label();                        
                            label1.Text = dr.GetValue(3).ToString();
                            cel1.Controls.Add(label1);
                            cel1.ColSpan = 4;
                            row1.Cells.Add(cel1);
                            table2.Rows.Add(row1);
                            for (int i = 4; i <8; i++)
                            {
                                HtmlTableCell cell = new HtmlTableCell();
                                RadioButton radioButton = new RadioButton();
                                Label lblno = new Label();
                                lblno.Text = "(" + (i-3).ToString() + ")";
                                cell.Controls.Add(lblno);
                                radioButton.Text = dr.GetValue(i).ToString();
                                radioButton.GroupName = dr.GetValue(3).ToString();
                                radioButton.ID = dr.GetValue(i).ToString();
                                
                                cell.Controls.Add(radioButton);
                                row.Cells.Add(cell);
                                                     
                           }
                            table2.Rows.Add(row);
                            
                        
                    }
                }
                con_data.con.Close();
            }
            catch (Exception ex)
            {

            }
            finally
            {
                if (con_data.con.State == ConnectionState.Open)
                {
                    con_data.con.Close();
                }
            }
Posted
Updated 20-Nov-14 2:56am
v3
Comments
Sinisa Hajnal 20-Nov-14 9:09am    
You will have to clarify the question (a lot) for us to be able to answer it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900