using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCN"].ConnectionString)) { btnRegister.Text = "Update"; SqlCommand cmd = new SqlCommand("Usp_Register", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Mode", "ViewProfile"); con.Open(); SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); da.SelectCommand = cmd; da.Fill(dt); if (dt != null && dt.Rows.Count > 0) { txtName.Text = dt.Rows[0]["EmpName"].ToString(); txtPassword.Text = dt.Rows[0]["Password"].ToString(); //txtPassword.Enabled = false; txtUserName.Text = dt.Rows[0]["UserName"].ToString(); txtDesignation.Text = dt.Rows[0]["EmpDesignation"].ToString(); txtMobileNumber.Text = dt.Rows[0]["Empnumber"].ToString(); txtEmailId.Text = dt.Rows[0]["EmpEmail"].ToString(); bindRole(); comboboxRole.SelectedValue = dt.Rows[0]["EmpRole"].ToString(); dateTimePickerJoinDate.Value = Convert.ToDateTime(dt.Rows[0]["JoinDate"].ToString()); dateTimePickerDOB.Value = Convert.ToDateTime(dt.Rows[0]["DOB"].ToString()); if (dt.Rows[0]["Gender"].ToString() == "Male") { radioButtonMale.Checked = true; } else if (dt.Rows[0]["Gender"].ToString() == "Female") { radioButtonFemale.Checked = true; } } else { MessageBox.Show("No Data in dt"); } }
public void bindRole() { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCN"].ConnectionString)) { DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("Select * from EmpRole Order by RoleName", con); con.Open(); da.Fill(ds, "EmpRole"); comboboxRole.DisplayMember = "RoleName"; comboboxRole.ValueMember = "RoleId"; comboboxRole.DataSource = ds.Tables["EmpRole"]; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)