One of the variables you are trying to read from or write to is Null
, i.e. has no value yet. The line number in your error message should tell you where this occurs.
You can avoid this by using for instance:
if(yourVariable != null){
// do something with the variable
}
My guess is that this stems from upload.selectedValue
- are you sure this is set? You can try replacing the first part of your code with the following:
if(!string.IsNullOrEmpty(upload.selectedValue)
&& (upload.selectedValue == "allupload"))
{
// do stuff with theModel
}
If that removes the error, you just have to figure out why upload.selectedValue
is not set.