ComboBox SelectedItem gets null reference error

  1. #1

    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?
  2. #2
    Figured this one out with help from this thread:

    Now rather than setting a value this way:
    this.ddlSubmissionStatus.SelectedItem.Value = viewSubmission.SubmissionStatus;

    You have to set it this way:
    this.ddlSubmissionStatus.SelectedItems.Add(new Ext.Net.ListItem(viewSubmission.SubmissionStatus)) ;

    The Clear gets rid of any previous selections and the UpdateSelectedItems makes your new selection go through.

Similar Threads

  1. Replies: 0
    Last Post: Jun 12, 2012, 10:00 AM
  2. [CLOSED] Null Reference Object Ajax
    By Oliver in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 01, 2012, 1:18 PM
  3. ComboBox SelectedItem Null
    By camazorro in forum 1.x Help
    Replies: 2
    Last Post: Jan 20, 2012, 7:58 PM
  4. Replies: 4
    Last Post: Nov 30, 2011, 5:25 AM
  5. [CLOSED] IE7 Runtime Error on SelectedItem for ComboBox (Hidden Tab)
    By bfolger in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 17, 2009, 8:35 AM

Tags for this Thread

Posting Permissions