i have a dropdownlist that gets populated on pageload event.
now i want that as soon as i select that persons name in dropdown its all information and person working under him should populate in datagridview1 and datagridview2 respectively
please suggest i ma new to this tecnology
Here is the code:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string CS = ConfigurationManager.ConnectionStrings["hodconstr"].ConnectionString;
using (SqlConnection con = new SqlConnection("hodconstr"))
using (SqlCommand cmd = new SqlCommand("Select * from EMPLOYEE where DESIGNATIO = 'hod' AND ACTIVE = 'N'"))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataSet ds = new DataSet();
sda.Fill(ds);
DDL1.DataSource = ds.Tables[0];
DDL1.DataTextField = "Name";
DDL1.DataValueField = "CustomerId";
DDL1.DataBind();
}
}
} DDL1.Items.Insert(0, new ListItem("--Select Inactive HOD'S--", "0"));
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string CS = ConfigurationManager.ConnectionStrings["hodconstr"].ConnectionString;
using (SqlConnection con = new SqlConnection("hodconstr"))
using (SqlCommand cmd = new SqlCommand("Select EMP_NAME, EMP_CODE, EMP_DEPT, DEPARTMENT, DESIGNATIO from EMPLOYEE WHERE "))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataSet ds = new DataSet();
sda.Fill(ds);
GV1.DataSource = ds.Tables[0];
GV1.DataBind();
}
}
}
}
}