0

I have what is a very elementary problem I realize, I am trying to return a string value from a selected value of a DropDownList upon selected index change but for some or other reason it is not happening.

 protected void drpMinisters_SelectedIndexChanged(object sender, EventArgs e)
{
    name = drpMinisters.SelectedValue;
    LabMessage.Text = name;

}

When I try to add name to a database I get a NullReferenceException.

Advice perhaps

4

2 回答 2

3

i guess you are talking about the asp.net dropdown list control

use drpMinisters.Text to get the selected value (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.text.aspx)

于 2012-11-30T08:55:27.627 回答
0

You can try something like this if you are using ASP .net var ddValue= document.getElementById("your Drop Down List Item").options[document.getElementById("your Drop Down List Item").selectedIndex].text; I was facing same problem it solved my problem with

"NullReferenceException"

于 2012-11-30T09:51:35.410 回答