PC Review


Reply
Thread Tools Rate Thread

combo box populated but selectedItem returning system.Data.DataRowView

 
 
Jerry
Guest
Posts: n/a
 
      6th May 2007
Hi

I have a combo box that is populated by an ole db connection to a ms access
table (Valuewave). The column that is used in the table is called waves.

The combo box is populated with the correct values, but when I refer to the
selectedItem value using WaveItem = cboWaves.SelectedItem.ToString();
MessageBox.Show(WaveItem);
I get System.Data.DataRowView. I have checked the spelling of the database
in the connection string, the table, and the column and they are correct.
How can I resolve this?

Doug




 
Reply With Quote
 
 
 
 
Jerry
Guest
Posts: n/a
 
      6th May 2007
Sorry I should have copied my code:

OleDbCommand strCommand = new OleDbCommand(strSelect, myConnection);

OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(strCommand);

myConnection.Open();

DataSet DS = new DataSet();

myDataAdapter.Fill(DS);

cboWaves.DataSource = DS.Tables[0];

cboWaves.DisplayMember = "Valuewave";

cboWaves.ValueMember = "waves";

WaveItem = ((DataRowView)cboWaves.SelectedItem)["waves"].ToString();



I am changed the assignment of waveItem from my first post.



Doug





"Jerry" <(E-Mail Removed)> wrote in message
news:463d3054$0$15199$(E-Mail Removed)...
> Hi
>
> I have a combo box that is populated by an ole db connection to a ms
> access table (Valuewave). The column that is used in the table is called
> waves.
>
> The combo box is populated with the correct values, but when I refer to
> the selectedItem value using WaveItem = cboWaves.SelectedItem.ToString();
> MessageBox.Show(WaveItem);
> I get System.Data.DataRowView. I have checked the spelling of the
> database in the connection string, the table, and the column and they are
> correct. How can I resolve this?
>
> Doug
>
>
>
>



 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      6th May 2007
Jerry,
the Items in a databound ComboBox actually *are* DataRowViews. This short
code snippet may help:

DataRowView recRowView = cboName.SelectedItem;
DataRow recName = recRowView.Row;
lblAccountNum.Text = recName.AccountNum;
lblCompanyName.Text = recName.CompanyName;
--Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"Jerry" wrote:

> Hi
>
> I have a combo box that is populated by an ole db connection to a ms access
> table (Valuewave). The column that is used in the table is called waves.
>
> The combo box is populated with the correct values, but when I refer to the
> selectedItem value using WaveItem = cboWaves.SelectedItem.ToString();
> MessageBox.Show(WaveItem);
> I get System.Data.DataRowView. I have checked the spelling of the database
> in the connection string, the table, and the column and they are correct.
> How can I resolve this?
>
> Doug
>
>
>
>
>

 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      6th May 2007

"Jerry" <(E-Mail Removed)> wrote in message
news:463d35fa$0$23513$(E-Mail Removed)...
> Sorry I should have copied my code:
>
> OleDbCommand strCommand = new OleDbCommand(strSelect, myConnection);
>
> OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(strCommand);
>
> myConnection.Open();
>
> DataSet DS = new DataSet();
>
> myDataAdapter.Fill(DS);
>
> cboWaves.DataSource = DS.Tables[0];
>
> cboWaves.DisplayMember = "Valuewave";
>
> cboWaves.ValueMember = "waves";
>
> WaveItem = ((DataRowView)cboWaves.SelectedItem)["waves"].ToString();
>
>
>
> I am changed the assignment of waveItem from my first post.
>
>


That cbobox is being loaded from the DS.Tables[0] like it's view/object
collection.

The simplest way to deal with this is you're going to have to walk/read the
record set and do cboWaves.additem (record set field), until you reach the
end of the record set.


 
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
Re: Noob question - binding data to list box (system.data.datarowview?) Lloyd Sheen Microsoft ASP .NET 0 17th Apr 2008 05:23 PM
DropDownList SelectedItem returns System.Data.DataRowView??? jim Microsoft Dot NET Framework Forms 2 2nd Mar 2004 08:41 PM
System.Data.DataRowView =?Utf-8?B?RGF2ZSBCYWlsZXk=?= Microsoft C# .NET 3 23rd Jan 2004 01:15 PM
System.Data.DataRowView André Almeida Maldonado Microsoft Dot NET 3 14th Oct 2003 08:09 PM
Re: Fill Combo :: "System.data.dataRowView" Peter Foot [MVP] Microsoft Dot NET Compact Framework 3 29th Jul 2003 03:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 PM.