By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,197 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,197 IT Pros & Developers. It's quick & easy.

Filling DataRow[] into combobox

P: n/a
Hi,
I do this:

this.comboBox.DataSource =
myDataSet.Tables["receivers"].Select("location_key = " +
selectedLocationKey);
this.comboBox.DisplayMember = "text";
this.comboBox.ValueMember = "subcustomer_location_key";

but get an exception when setting the value member. Unfortunately there
is something wrong with my debugger so I can't see what is in the
exception. I am sure that the columns are named "text" and
"subcustomer_location_key".
I have also tried with the table name: "subreceivers.text" and
"subreceivers.subcustomer_location_key". The same thing happens.

How do I refer to the columns of the data rows in the DataRow array so
that the combobox understands it?

Best regards,
Kim

Dec 18 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Kim,

Try loading the data into a new DataView class and use the RowFilter
property instead. You can bind to the DataView directly.

--
Dave Sexton

<ki***********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,
I do this:

this.comboBox.DataSource =
myDataSet.Tables["receivers"].Select("location_key = " +
selectedLocationKey);
this.comboBox.DisplayMember = "text";
this.comboBox.ValueMember = "subcustomer_location_key";

but get an exception when setting the value member. Unfortunately there
is something wrong with my debugger so I can't see what is in the
exception. I am sure that the columns are named "text" and
"subcustomer_location_key".
I have also tried with the table name: "subreceivers.text" and
"subreceivers.subcustomer_location_key". The same thing happens.

How do I refer to the columns of the data rows in the DataRow array so
that the combobox understands it?

Best regards,
Kim

Dec 18 '06 #2

P: n/a
Hi,

What is wrong with your debugger?
the code seems to be ok but if you do not know what is going on is a little
difficult to know the reason.

Also a little more detail could help, what exception u r getting and where?
--
Ignacio Machin
machin AT laceupsolutions com

<ki***********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,
I do this:

this.comboBox.DataSource =
myDataSet.Tables["receivers"].Select("location_key = " +
selectedLocationKey);
this.comboBox.DisplayMember = "text";
this.comboBox.ValueMember = "subcustomer_location_key";

but get an exception when setting the value member. Unfortunately there
is something wrong with my debugger so I can't see what is in the
exception. I am sure that the columns are named "text" and
"subcustomer_location_key".
I have also tried with the table name: "subreceivers.text" and
"subreceivers.subcustomer_location_key". The same thing happens.

How do I refer to the columns of the data rows in the DataRow array so
that the combobox understands it?

Best regards,
Kim

Dec 18 '06 #3

P: n/a
Hi Kim,

I shouldn't have wrote "loading the data" since the DataView doesn't contain
any data at all, it just wraps the specified DataTable. In other words, you
should just create a "view" of the data that you want - using a DataView
won't actually copy the data into a new object.

DataView view = myDataSet.Tables["receivers"].DefaultView;
or
DataView view = new DataView(myDataSet.Tables["receivers"]);

view.RowFilter = "location_key=" + selectedLocationKey;

comboBox.DataSource = view;
comboBox.DisplayMember = "text";
comboBox.ValueMember = "subcustomer_location_key";

Also, you should think about strong-typing your DataSet.

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:u1**************@TK2MSFTNGP03.phx.gbl...
Hi Kim,

Try loading the data into a new DataView class and use the RowFilter
property instead. You can bind to the DataView directly.

--
Dave Sexton

<ki***********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
>Hi,
I do this:

this.comboBox.DataSource =
myDataSet.Tables["receivers"].Select("location_key = " +
selectedLocationKey);
this.comboBox.DisplayMember = "text";
this.comboBox.ValueMember = "subcustomer_location_key";

but get an exception when setting the value member. Unfortunately there
is something wrong with my debugger so I can't see what is in the
exception. I am sure that the columns are named "text" and
"subcustomer_location_key".
I have also tried with the table name: "subreceivers.text" and
"subreceivers.subcustomer_location_key". The same thing happens.

How do I refer to the columns of the data rows in the DataRow array so
that the combobox understands it?

Best regards,
Kim


Dec 18 '06 #4

P: n/a
Hi Dave!

Thank you for your help - it works. I had forgotten that the DataView
existed :-)

Best regards,
Kim Therkelsen

Hi Kim,

I shouldn't have wrote "loading the data" since the DataView doesn't contain
any data at all, it just wraps the specified DataTable. In other words, you
should just create a "view" of the data that you want - using a DataView
won't actually copy the data into a new object.

DataView view = myDataSet.Tables["receivers"].DefaultView;
or
DataView view = new DataView(myDataSet.Tables["receivers"]);

view.RowFilter = "location_key=" + selectedLocationKey;

comboBox.DataSource = view;
comboBox.DisplayMember = "text";
comboBox.ValueMember = "subcustomer_location_key";

Also, you should think about strong-typing your DataSet.

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:u1**************@TK2MSFTNGP03.phx.gbl...
Hi Kim,

Try loading the data into a new DataView class and use the RowFilter
property instead. You can bind to the DataView directly.

--
Dave Sexton

<ki***********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,
I do this:

this.comboBox.DataSource =
myDataSet.Tables["receivers"].Select("location_key = " +
selectedLocationKey);
this.comboBox.DisplayMember = "text";
this.comboBox.ValueMember = "subcustomer_location_key";

but get an exception when setting the value member. Unfortunately there
is something wrong with my debugger so I can't see what is in the
exception. I am sure that the columns are named "text" and
"subcustomer_location_key".
I have also tried with the table name: "subreceivers.text" and
"subreceivers.subcustomer_location_key". The same thing happens.

How do I refer to the columns of the data rows in the DataRow array so
that the combobox understands it?

Best regards,
Kim
Dec 19 '06 #5

P: n/a
Hi Ignacio,
I think I have to rephrase the problem with the debugger.

I am developing software for a Windows CE 4.2 PDA. When I run the
software on the PDA from Visual Studio 2005 in debug mode and get an
exception, the contents of the exception can not be shown because some
sort of debugging information is missing.

To make the software made in VS2005 run on the PDA I had to install the
..Net compact framework 2.0 manually. I think somehow the missing debug
information is related to the installation of the .Net framework.

Best regards,
Kim

Hi,

What is wrong with your debugger?
the code seems to be ok but if you do not know what is going on is a little
difficult to know the reason.

Also a little more detail could help, what exception u r getting and where?
--
Ignacio Machin
machin AT laceupsolutions com

<ki***********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,
I do this:

this.comboBox.DataSource =
myDataSet.Tables["receivers"].Select("location_key = " +
selectedLocationKey);
this.comboBox.DisplayMember = "text";
this.comboBox.ValueMember = "subcustomer_location_key";

but get an exception when setting the value member. Unfortunately there
is something wrong with my debugger so I can't see what is in the
exception. I am sure that the columns are named "text" and
"subcustomer_location_key".
I have also tried with the table name: "subreceivers.text" and
"subreceivers.subcustomer_location_key". The same thing happens.

How do I refer to the columns of the data rows in the DataRow array so
that the combobox understands it?

Best regards,
Kim
Dec 19 '06 #6

P: n/a
Hi,
<ki***********@gmail.comwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
Hi Ignacio,
I think I have to rephrase the problem with the debugger.

I am developing software for a Windows CE 4.2 PDA. When I run the
software on the PDA from Visual Studio 2005 in debug mode and get an
exception, the contents of the exception can not be shown because some
sort of debugging information is missing.
Weird, are you getting something about "resource assembly" ?
To make the software made in VS2005 run on the PDA I had to install the
.Net compact framework 2.0 manually. I think somehow the missing debug
information is related to the installation of the .Net framework.
I had never need to install the framework manually, it's always installed
from the IDE when you run the app.

I think you have something wrong with your dev. environment.

--
Ignacio Machin
machin AT laceupsolutions com
Dec 19 '06 #7

P: n/a
Hi again,

I get the message:
"An error message cannot be displayed because an optional resource
assembly containing it cannot be found"
whenever I get an exception.

It IS necessary to install the .Net framework 2.0 manually:
http://blogs.msdn.com/markprenticems...08/692624.aspx

Best regards,
Kim

Ignacio Machin ( .NET/ C# MVP ) skrev:
Hi,
<ki***********@gmail.comwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
Hi Ignacio,
I think I have to rephrase the problem with the debugger.

I am developing software for a Windows CE 4.2 PDA. When I run the
software on the PDA from Visual Studio 2005 in debug mode and get an
exception, the contents of the exception can not be shown because some
sort of debugging information is missing.

Weird, are you getting something about "resource assembly" ?
To make the software made in VS2005 run on the PDA I had to install the
.Net compact framework 2.0 manually. I think somehow the missing debug
information is related to the installation of the .Net framework.

I had never need to install the framework manually, it's always installed
from the IDE when you run the app.

I think you have something wrong with your dev. environment.

--
Ignacio Machin
machin AT laceupsolutions com
Dec 20 '06 #8

P: n/a
Hi,

This seems like the old "resource assembly" error in 1.1, maybe is the same
one.

Check the blog of the CF to see if there are answers there.
--
Ignacio Machin
machin AT laceupsolutions com

<ki***********@gmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
Hi again,

I get the message:
"An error message cannot be displayed because an optional resource
assembly containing it cannot be found"
whenever I get an exception.

It IS necessary to install the .Net framework 2.0 manually:
http://blogs.msdn.com/markprenticems...08/692624.aspx

Best regards,
Kim

Ignacio Machin ( .NET/ C# MVP ) skrev:
>Hi,
<ki***********@gmail.comwrote in message
news:11**********************@n67g2000cwd.googleg roups.com...
Hi Ignacio,
I think I have to rephrase the problem with the debugger.

I am developing software for a Windows CE 4.2 PDA. When I run the
software on the PDA from Visual Studio 2005 in debug mode and get an
exception, the contents of the exception can not be shown because some
sort of debugging information is missing.

Weird, are you getting something about "resource assembly" ?
To make the software made in VS2005 run on the PDA I had to install the
.Net compact framework 2.0 manually. I think somehow the missing debug
information is related to the installation of the .Net framework.

I had never need to install the framework manually, it's always installed
from the IDE when you run the app.

I think you have something wrong with your dev. environment.

--
Ignacio Machin
machin AT laceupsolutions com

Dec 21 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.