How to get only first value from DropDownList selected item
Hi,I have loaded the multiple column value in single dropdownlist control. And I want to show the first column value only when i select the dropdownlist item. Below is my code.
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from employee";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "employee");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DropDownList1.Items.Add(ds.Tables[0].Rows[i]["empname"] +"---" + ds.Tables[0].Rows[i]["empaddress"].ToString());
}
con.Close();
}
When i select the item i want just show the EmployeeName only in dropdown list.