hi im new to c# and .net2.0 can anybody plz help ...... i have all the details of empid in dropdown listbox and if i click the empid the date related to that id shoul de displayed...... ... i have attached the code...plz say me the corrections.... .
Code:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
// CODE FOR GETTING THE DATA FROM SQLTABEL
int employeeid = Convert.ToInt16(DropDownList1.SelectedIndex);
SqlConnection con = new SqlConnection("Data Source=MS1;Initial Catalog=MSRegSys;uid=sa;Password=ms123");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select EmpID,EmpCode,lo.LocationName,dp.DepName from usr_tblMs_Employee em INNER JOIN usr_tblMs_Department dp ON dp.DeptID=em.DeptID INNER JOIN usr_tblMs_Location lo ON lo.LocationID=dp.LocationID where em.EmpID=employeeid ", con);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt=ds.Tables["e"];
DataRow dr = dt.Rows[0];
DropDownList1.Text = dr[0].ToString();
txtempcode.Text = dr[1].ToString();
txtdept.Text = dr[2].ToString();
txtlocation.Text = dr[3].ToString();
}
Comment