if you want to show both the things then you have to concatenate the values where you are fetching the records for binding the dropdownlist, i am pasting the code, which will tell you how you can get the experience by name(selected value in dropdown)
first step is :
save the datatable from which you are binding the dropdown into ViewState
then on dropdown's selectedindexchanged event use the following code:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (ViewState["dt"] != null)
{
DataTable dt = (DataTable)ViewState["dt"];
if (dt.Rows.Count > 0)
{
string sqlFilter = "name = '" + DropDownList1.SelectedItem.Text + "'";
DataRow[] data = dt.Select(sqlFilter);
if (data.Length > 0)
{
TextBox1.Text = data["Exp"].ToString();
}
}
}
}
or if you want to pass it to db to get the experience and location then do it in the following way:
clsArtBook obj = new clsArtBook();
DataTable dt = new DataTable();
dt = obj.getDetailsbyName(DropDownList1.SelectedItem.Text);
if (dt.Rows.Count > 0) {
TextBox1.Text = dt.Rows[0]["expeince"].ToString();
TextBox1.Text = dt.Rows[0]["location"].ToString();
}
create a stored proc which will get the details by name like :
create proc proc_GetDetailsByName
(
@name varchar(100)
)
as
if exists(select 1 from tblemployee where name=@name)
begin
select location,experince from tblemployee where name=@name
end
it will resolve your problem