ComboBox.DataSource = {DataView}; But after is still = Nothing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Brunson

    ComboBox.DataSource = {DataView}; But after is still = Nothing

    I've got a very weird problem, when I run the following code the
    ComboBox (Me.cmbInputDev ice) is always empty. The ComboBox is on a
    UserControl in a Class Library. I'm using VS.NET 2003 with SourceSafe
    6.0d (the problem occurs whether the code is checked in or out)

    If I step through the code, The line

    Me.cmbInputDevi ce.DataSource = dv

    Executes fine (ie, doesn't error), but on the next line (after an
    F8/F11) Me.cmbInputDevi ce.DataSource is still equal to Nothing.

    dv is definately not Nothing, and is definately not empty (I can view
    it's contents in the Command Window)

    *if* I delete the combo box from the control, and add a new one, give it
    the same name, etc, it works for a while, but then goes back to
    not-working after an unknown period. This isn't any kind of practical
    solution.


    Sql.GetDeviceTa ble() returns a valid & populated DataTable

    [VB.NET] (Native Language)

    Dim dt As DataTable = Sql.GetDeviceTa ble()

    Dim dr As DataRow = dt.NewRow()
    dr("ID") = DBNull.Value
    dr("Description ") = "<None>"
    dt.Rows.Add(dr)

    Dim dv As DataView = dt.DefaultView
    dv.Sort = "Descriptio n"
    dv.ApplyDefault Sort = True

    Me.cmbInputDevi ce.DataSource = dv
    Me.cmbInputDevi ce.DisplayMembe r = "Descriptio n"
    Me.cmbInputDevi ce.ValueMember = "ID"

    [C#] (Translation)

    DataTable dt = Sql.GetDeviceTa ble();

    DataRow dr = dt.NewRow();
    dr("ID") = DBNull.Value;
    dr("Description ") = "<None>";
    dt.Rows.Add(dr) ;

    DataView dv = dt.DefaultView;
    dv.Sort = "Descriptio n";
    dv.ApplyDefault Sort = True;

    this.cmbInputDe vice.DataSource = dv;
    this.cmbInputDe vice.DisplayMem ber = "Descriptio n";
    this.cmbInputDe vice.ValueMembe r = "ID";
Working...