combobox datasource

T

Tamir Khason

Why this does not work???

cb1 - combobox
DataProvider.DataProvider.DS_BringRacks() - DataSet
cb1.DataSource=DataProvider.DataProvider.DS_BringRacks().Tables[0];

cb1.DisplayMember = "id";

cb1.ValueMember = cb1.DisplayMember;

it diplays in combobox : "System.Data.DataRowView" instead of real values.
in debug view I can see that the dataset contants 1 column, named "id" with
3 rows, which have values.

So why this do not working???
 
J

Jerry Negrelli

Does this work??

dvExample = new DataView
(DataProvider.DataProvider.DS_BringRacks().Tables
[0], "", "id ASC", DataViewRowState.OriginalRows);

cb1.DataSource = dvExample;
cb1.DisplayMember = "id";
cb1.ValueMember = cb1.DisplayMember;


Jerry Negrelli
Senior Software Engineer
Data Scientific Corporation
 
T

Tamir Khason

Nop, tried as well to create absolute new dataset - nothing...
I'm afraid it's because of event looker (I have event onindexchage on this
combobox for some reason it fired event BEFORE the application fully up on
dataload...)

What do you think?


Jerry Negrelli said:
Does this work??

dvExample = new DataView
(DataProvider.DataProvider.DS_BringRacks().Tables
[0], "", "id ASC", DataViewRowState.OriginalRows);

cb1.DataSource = dvExample;
cb1.DisplayMember = "id";
cb1.ValueMember = cb1.DisplayMember;


Jerry Negrelli
Senior Software Engineer
Data Scientific Corporation
-----Original Message-----
Why this does not work???

cb1 - combobox
DataProvider.DataProvider.DS_BringRacks() - DataSet
cb1.DataSource=DataProvider.DataProvider.DS_BringRacks ().Tables[0];

cb1.DisplayMember = "id";

cb1.ValueMember = cb1.DisplayMember;

it diplays in combobox : "System.Data.DataRowView" instead of real values.
in debug view I can see that the dataset contants 1 column, named "id" with
3 rows, which have values.

So why this do not working???


.
 
J

Jeffrey Tan[MSFT]

Hi Tamir,

Based on my understanding, in your
DataProvider.DataProvider.DS_BringRacks(), it means that DataProvider
namespace contains a DataProvider class whoes DS_BringRacks() method
returns a dataset.

I think you should check if your dataset is generated correctly.
If it is generated well, I think your problem must be the DisplayMember. I
think the "id" field you assign to DisplayMember is not the correctly field
name in the dataset.

Sample listed below, this works well:(I use the default sql server database
to generate the dataset then bind it to combobox)

SqlDataAdapter adapter=new SqlDataAdapter("select * from
jobs","server=localhost;database=pubs;user=sa;pwd=");
DataSet ds=new DataSet();
adapter.Fill (ds);
comboBox1.DataSource=ds.Tables[0];
comboBox1.DisplayMember="job_desc";
comboBox1.ValueMember =comboBox1.DisplayMember ;

While I change the "job_desc" to "job_des"(Lost one character), then the
combobox will display "System.Data.DataRowView".

If you have anything unclear, please feel free to let me know

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Tamir Khason" <[email protected]>
| References: <ukRkS#[email protected]>
<[email protected]>
| Subject: Re: combobox datasource
| Date: Mon, 10 Nov 2003 19:17:06 +0200
| Lines: 50
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 198.211.173.74
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:198111
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Nop, tried as well to create absolute new dataset - nothing...
| I'm afraid it's because of event looker (I have event onindexchage on this
| combobox for some reason it fired event BEFORE the application fully up on
| dataload...)
|
| What do you think?
|
|
message
| | > Does this work??
| >
| > dvExample = new DataView
| > (DataProvider.DataProvider.DS_BringRacks().Tables
| > [0], "", "id ASC", DataViewRowState.OriginalRows);
| >
| > cb1.DataSource = dvExample;
| > cb1.DisplayMember = "id";
| > cb1.ValueMember = cb1.DisplayMember;
| >
| >
| > Jerry Negrelli
| > Senior Software Engineer
| > Data Scientific Corporation
| >
| > >-----Original Message-----
| > >Why this does not work???
| > >
| > >cb1 - combobox
| > >DataProvider.DataProvider.DS_BringRacks() - DataSet
| > >cb1.DataSource=DataProvider.DataProvider.DS_BringRacks
| > ().Tables[0];
| > >
| > >cb1.DisplayMember = "id";
| > >
| > >cb1.ValueMember = cb1.DisplayMember;
| > >
| > >it diplays in combobox : "System.Data.DataRowView"
| > instead of real values.
| > >in debug view I can see that the dataset contants 1
| > column, named "id" with
| > >3 rows, which have values.
| > >
| > >So why this do not working???
| > >
| > >
| > >.
| > >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top