Re: Retrieving the selected item from the dropdown list and storing it in a local variable

Tech-Archive recommends: Fix windows errors by optimizing your registry



What is the error?

In any case, set a breakpoint on that line and check if all the properties
you are using contain the values you are expecting.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


<yasodhai@xxxxxxxxx> wrote in message
news:1173257496.153708.190680@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I used a dropdown control which is binded to a datagrid control. I
passed the values to the dropdownlist from the database using a
function as follows in the aspx itself.

<asp:DropDownList ID="FldType_add" Runat="server" DataSource='<
%#GetFieldType()%>' DataValueField="Type" DataTextField="Type" />

Oce the page is loaded all the values are added to the dropdown list.
But when I thought of getting the selected value from the dropdown
list, I am getting the following error while assigning the value to a
local variable called Fldstr.

DropDownList
Fldlist=(DropDownList)e.Item.FindControl("FieldType_add");
string Fldstr=Fldlist.SelectedItem.Value;

Here FieldType_add is the id of the dropdown list form which i am
going to retrieve the selected value. Kindly help me to come out from
this.


Regards,
Yasodhai



.


Quantcast