PC Review


Reply
Thread Tools Rate Thread

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

 
 
Jon Brunson
Guest
Posts: n/a
 
      12th Jan 2005
I've got a very weird problem, when I run the following code the
ComboBox (Me.cmbInputDevice) 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.cmbInputDevice.DataSource = dv

Executes fine (ie, doesn't error), but on the next line (after an
F8/F11) Me.cmbInputDevice.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.GetDeviceTable() returns a valid & populated DataTable

[VB.NET] (Native Language)

Dim dt As DataTable = Sql.GetDeviceTable()

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 = "Description"
dv.ApplyDefaultSort = True

Me.cmbInputDevice.DataSource = dv
Me.cmbInputDevice.DisplayMember = "Description"
Me.cmbInputDevice.ValueMember = "ID"

[C#] (Translation)

DataTable dt = Sql.GetDeviceTable();

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

DataView dv = dt.DefaultView;
dv.Sort = "Description";
dv.ApplyDefaultSort = True;

this.cmbInputDevice.DataSource = dv;
this.cmbInputDevice.DisplayMember = "Description";
this.cmbInputDevice.ValueMember = "ID";
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataView as DataSource =?Utf-8?B?QW50?= Microsoft ADO .NET 6 23rd May 2006 03:03 PM
ComboBox.DataSource = {DataView}; But after is still = Nothing Jon Brunson Microsoft Dot NET Framework 0 12th Jan 2005 01:20 PM
ComboBox.DataSource = {DataView}; But after is still = Nothing Jon Brunson Microsoft VB .NET 0 12th Jan 2005 01:20 PM
ComboBox.DataSource = {DataView}; But after is still = Nothing Jon Brunson Microsoft Dot NET 0 12th Jan 2005 01:20 PM
ComboBox.DataSource .Net v1.1.4322: Problem to assign new datasource Stephan Microsoft Dot NET Framework 3 10th Oct 2003 08:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:42 AM.