0

I made a user control having 4 dropdown list and I want to get their selected value in .aspx where I am referring this User Control. I use multiple options to get the selected value of ddl from User Control but each time its giving error " Object reference not set to an instance of Object". Here is code I am using

In your WebUserControl (user control) code-behind file, you could have something like this:

In WebUserControl (user control) code-behind file

public string DropDownSelectedValue
{
    get
    {
       return dropDown.SelectedValue;
    }
}

In web page where I am using that user control // Assuming I have defined usercontrol with the 'yourUserControl' ID

string selectedValue = yourUserControl.DropDownSelectedValue;
  • 2
    Hello, and welcome to stackoverflow. if the general advice from [What is a NullReferenceException, and how do I fix it](https://stackoverflow.com/q/4660142/3744182) isn't enough to solve your problem, then you can ask a new question (or [edit] this question) and include a [mcve] that demonstrates the problem and explains the specific problem you encountered and why you couldn't resolve it. – dbc Oct 02 '17 at 05:39
  • 1
    As per my understanding, your `yourUserControl` is `null`. you need to `initialize` it. – mmushtaq Oct 02 '17 at 05:49
  • No, thats not the case, If I access that dropDown.Selected value with in the user control it works, plus if I return some other string it also works, I don't know wht it isn't working for the dropdown.Selected Value to return – Zunaira Sattar Oct 03 '17 at 05:35

0 Answers0