lundi 27 juin 2016

dynamically created checkbox in c# using asp.net show vertically

I am designed the checkbox dynamically in c# with in contentplace holder i want to order in vertical and only one box only checked at a time in code behind give the solution.code given below,

DataTable table = new DataTable();

table.Columns.Add("Betoption", typeof(string));
table.Columns.Add("id", typeof(string));
table.Rows.Add("Main", "1");
table.Rows.Add("Corner", "2");
table.Rows.Add( "Card & Foul", "3");
table.Rows.Add( "Under / Over", "4");
table.Rows.Add( "Dilantin", "5");
table.Rows.Add( "Home / Away", "6");
table.Rows.Add("First Half", "7");

DataRow[] exemption = table.Select();

foreach (DataRow dr in exemption)
{
    string option = dr["Betoption"].ToString();
    string optionID = dr["id"].ToString();


    var chk = new CheckBox { ID = optionID, Text = option, CssClass = "name", AutoPostBack = true };

    PlaceHolder1.Controls.Add(chk);

} 




Aucun commentaire:

Enregistrer un commentaire