[SOLVED] How to get Value from DropDownList inside a ListView?


I have a DropDownList inside in ListView..
I wanted to get a data when command clicked.
this is my code..

protected void ListView2_ItemCommand(object sender, ListViewCommandEventArgs e){

string shipmethod = ((DropDownList)e.Item.FindControl("ShippingComapnyDDL")).SelectedValue;


but it always return null value..
I’ve googling about 3 hours, and try many function..
but still cant solve this bug..

please help me guys,

here’s my aspx page

 <asp:DropDownList ID="ShippingComapnyDDL"  runat="server" SelectedValue='<%# Eval("ShippingCompany") %>'>
<asp:ListItem Text="" Value=""></asp:ListItem>
<asp:ListItem Text="FedEx" Value="FedEx"></asp:ListItem>
<asp:ListItem Text="UPS" Value="UPS"></asp:ListItem>
<asp:ListItem Text="Other" Value="Other"></asp:ListItem>


DO you have headers set?try

     string shipmethod = ((DropDownList)e.Item.FindControl("ShippingComapnyDDL")).SelectedValue; 

if not working then try     
string shipmethod = (e.Item.FindControl("ShippingComapnyDDL") as DropDownList).SelectedValue; 

Answered By – Krishnanunni Jeevan

Answer Checked By – Senaida (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *