# Web Development > ASP.NET DropDown in DataList

## Sreedevi Pidaparthi

I have datalist and in the Item template i have taken a dropdown list in a ASP.NET 1.1 web application. I have populated the dropdown at runtime. Now i want to capture the value selected in the DropDown. I tried SelectedIndexChanged procedure of the DropDown and the DataList and ItemCommand of DataList but to no avail. These events are being fired but i have no clue on how to capture the value selected in the DropDown List..... When an item in the drop Down is selected then the ItemCommand event of the datalist isnt triggered.....Please Help.

Thanks in Advance.
Sreedevi
 :Smile:

----------


## psuresh1982

Check whether the ValueField has unique values or not....

-------------------
suresh

----------


## Suyash123

protected void drp1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList ddl = (DropDownList)sender;

        string contactid = ddl.SelectedIndex.ToString();


// to access any other element in datalist
  //        DataListItem row = ddl.NamingContainer as DataListItem;

 //Label lbl = (Label)row.FindControl("lbl_text");

 if (ddl.SelectedItem.Text != "-Select-")
{
     ....
}
else
{

}
}

}

----------


## chinnakulandaiv

protected void drp1_SelectedIndexChanged(object sender, EventArgs e)
{
    string selectedValue=drp1.SelectedValue.ToString().Trim();

//Do rest of the code

}

this will help u to get the selected value from the drop down list

----------


## akanshu

protected void drp1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;

string contactid = ddl.SelectedIndex.ToString();


// to access any other element in datalist
// DataListItem row = ddl.NamingContainer as DataListItem;

//Label lbl = (Label)row.FindControl("lbl_text");

if (ddl.SelectedItem.Text != "-Select-")
{
....
}
else
{

}
}

}

----------

