473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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";
Nov 16 '05 #1
0 3264

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jon Brunson | last post by:
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...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
8
by: Steve B. | last post by:
My Program: a local C# ADO.Net application using VS 2003 Right now I have about 5 ComboBox's which provides drop down selection entries from the same MS-Access table via a DataConnection,...
2
by: Vern | last post by:
I have a combobox called sPropertyCountyCd whose datasource is a dataview. The first time I set the filter to the dataview, attach the combobox to the dataview, and set the selected index to -1 is...
5
by: jaYPee | last post by:
i have successfully added a combobox to my datagrid by setting their datasource from one of my table. here's my code... Dim grdColStyle6 As New DataGridComboBoxColumn() With grdColStyle6...
20
by: MadCrazyNewbie | last post by:
Hey group, I keep getting the following error: "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at...
2
by: pmcguire | last post by:
OK. So I've been to http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp and learned a lot about what I might do with a datagrid. But I'm STILL not able to do what I want to do. I want to be able...
11
by: Doug Bell | last post by:
Hi, I have a problem with a ComboBox bound to a DataView. The ComboBox shows the correct number of rows but instead of the data, each row shows "System.Data.DataRowView" Can someone explain how...
4
by: pmcguire | last post by:
I have 2 bound ComboBoxes. I want the datasource of the second to be limited by the selection made in the first. I can do this by responding to the SelectionIndexChanged event on the first, but...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.