SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); string query = "select attenday , slot , present from attendance where name = '" + DropDownList1.Text + "'"; DataTable dtAdmin = new DataTable(); SqlDataAdapter da; da = new SqlDataAdapter(query, con); da.Fill(dtAdmin); if (dtAdmin.Rows.Count > 0) { SqlCommand cmd = new SqlCommand(query, con); SqlDataReader dbr; con.Open(); dbr = cmd.ExecuteReader(); while (dbr.Read()) { string attenday = (string)dbr["attenday"].ToString(); string slot = (string)dbr["slot"].ToString(); string presentday = (string)dbr["present"].ToString(); if (attenday == "1") { DropDownList2.Text = slot; Label1.Text = presentday; } else if (attenday == "2") { DropDownList3.Text = slot; Label3.Text = presentday; } else if (attenday == "3") { DropDownList4.Text = slot; Label5.Text = presentday; } else if (attenday == "4") { DropDownList5.Text = slot; Label7.Text = presentday; } else if (attenday == "5") { DropDownList6.Text = slot; Label9.Text = presentday; } else if (attenday == "6") { DropDownList7.Text = slot; Label2.Text = presentday; } else if (attenday == "7") { DropDownList8.Text = slot; Label4.Text = presentday; } else if (attenday == "8") { DropDownList9.Text = slot; Label6.Text = presentday; } else if (attenday == "9") { DropDownList10.Text = slot; Label8.Text = presentday; } else if (attenday == "10") { DropDownList11.Text = slot; Label10.Text = presentday; } } dbr.Close();
Label6
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Call Your Function } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)