Jul 30, 2012, 8:29 PM
ComboBox SelectedItem gets null reference error
Upgrading from 1.X to 2.0 I am running into an issue with the ComboBox and the SelectedItem property on the back-end. I know breaking change #50 says the SelectedIndex and SelectedItem properties have been removed, but from the example that seems to only be on the front end. On the back end I can still access that property, but it seems like I can never fill it. (I always get a null reference error - "Object Reference Not Set to an Instance of an Object").
Here's the code I have (I also tried setting the SelectedItem.Text instead, but got the same result):
this.ddlSubmissionStatus.SelectedItem.Value = viewSubmission.SubmissionStatus;
I created a new textbox and used the same value to populate that and it works and shows up without an issue so I can guarantee that the value from the database is not null. This code works:
this.tfCurrentStatus.Text = viewSubmission.SubmissionStatus;
Is there something I'm doing wrong or is there a new way to set the selected value in a ComboBox on the back-end with 2.0?
Here's the code I have (I also tried setting the SelectedItem.Text instead, but got the same result):
this.ddlSubmissionStatus.SelectedItem.Value = viewSubmission.SubmissionStatus;
I created a new textbox and used the same value to populate that and it works and shows up without an issue so I can guarantee that the value from the database is not null. This code works:
this.tfCurrentStatus.Text = viewSubmission.SubmissionStatus;
Is there something I'm doing wrong or is there a new way to set the selected value in a ComboBox on the back-end with 2.0?