Create DataTable
DataTable dt = new DataTable();dt.Columns.Add(new DataColumn("Id"));
dt.Columns.Add(new DataColumn("Name"));
dt.Columns.Add(new DataColumn("Loc"));
DataRow dr = dt.NewRow();
dr[0] = "1";
dr[1] = "siva";
dr[2]="hyd";
DataRow dr1 = dt.NewRow();
dr1[0] = "2";
dr1[1] = "krishna";
dr1[2]="delhi";
DataRow dr2 = dt.NewRow();
dr2[0] = "3";
dr2[1] = "ravi";
dr2[2]="banga";
dt.Rows.Add(dr1);
dt.Rows.Add(dr2);
dt.Rows.Add(dr3);
//Now we have added a single row to the data table, you can use this datatable to populate a grid view or //other data presentation controls
GridView1.DataSource = dtHome;
GridView1.DataBind();
(or)
RadioButtonList1.DataSource = dt;
RadioButtonList1.DataTextField = "Name";
RadioButtonList1.DataValueField = "Id";
RadioButtonList1.DataBind();
RadioButtonList1.Items.Insert(0, "select one ");
(or)
CheckBoxList1.DataSource = dt;
CheckBoxList1.DataTextField = "Name";
CheckBoxList1.DataValueField = "Id";
CheckBoxList1.DataBind();
CheckBoxList1.Items.Insert(0, "select ");
No comments:
Post a Comment