Hi all,
I think I've stared at it until it's made me stupid(er?). What am I missing
about setting the list of the dropdown to display data pulled from a table?
//...
daPrepaid.Fill(dsPrepaid, "Seller");
cboSeller.DataSource = dsPrepaid.Tables["Seller"];
cboSeller.DisplayMember = "Name";
//...
When I assign the datasource, the dropdown's Text property changes to
"System.Data.DataRowView", which is then the only item in the list as well.
What's the stupid thing I'm not seeing?
TIA,
John 20 9354
Aren't you missing the cboSeller.ValueMember="Name"; <-- or whatever field ?
Greg
"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl... Hi all,
I think I've stared at it until it's made me stupid(er?). What am I missing about setting the list of the dropdown to display data pulled from a table?
//... daPrepaid.Fill(dsPrepaid, "Seller"); cboSeller.DataSource = dsPrepaid.Tables["Seller"]; cboSeller.DisplayMember = "Name"; //...
When I assign the datasource, the dropdown's Text property changes to "System.Data.DataRowView", which is then the only item in the list as well. What's the stupid thing I'm not seeing?
TIA,
John
John,
A change is in my opinion that "Name" is in the wrong case or even not in
your select..
That because you use three words cbo (combobox) and DropDown.
When cbo is a webpage dropdownlist than it is easy.
You miss
cboSeller.DataBind();
I hope this helps?
Cor
Hey Greg,
I had it in, but was getting an error. The strange thing is when I do
include ValueMember, the error message indicates a problem with binding to
DisplayMember, more specifically:
Could not bind to the new disply member.
Parameter name: newDisplayMember
A less abbreviated snippet...
OleDbCommand cmdPrepaid = conPrepaid.CreateCommand();
cmdPrepaid.CommandType = CommandType.Text;
cmdPrepaid.CommandText = "SELECT * FROM PrepaidSeller";
daPrepaid = new OleDbDataAdapter();
daPrepaid.SelectCommand = cmdPrepaid;
dsPrepaid = new DataSet();
conPrepaid.Open();
try
{
daPrepaid.Fill(dsPrepaid, "Seller");
cboSeller.DataSource = dsPrepaid.Tables["Seller"];
cboSeller.DisplayMember = "EntityName";
cboSeller.ValueMember = "CustKey";
//...
}
Thanks,
John
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... Aren't you missing the cboSeller.ValueMember="Name"; <-- or whatever field
? Greg
"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message news:eL**************@TK2MSFTNGP10.phx.gbl... Hi all,
I think I've stared at it until it's made me stupid(er?). What am I missing about setting the list of the dropdown to display data pulled from a table?
//... daPrepaid.Fill(dsPrepaid, "Seller"); cboSeller.DataSource = dsPrepaid.Tables["Seller"]; cboSeller.DisplayMember = "Name"; //...
When I assign the datasource, the dropdown's Text property changes to "System.Data.DataRowView", which is then the only item in the list as well. What's the stupid thing I'm not seeing?
TIA,
John
Hey Cor,
That's interesting. It was the case! I had used mixed case naming in
another piece a few days ago--but that was in a typed data set.
Thanks!
John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... John,
A change is in my opinion that "Name" is in the wrong case or even not in your select..
That because you use three words cbo (combobox) and DropDown.
When cbo is a webpage dropdownlist than it is easy. You miss cboSeller.DataBind();
I hope this helps?
Cor
John,
Always the same problem and than I forgot it. You cannot use reserved SQL
words as items and AFAIK is "Name" one of them.
Cor
> A change is in my opinion that "Name" is in the wrong case or even not in your select..
Cor, I don't believe case-sensitivity matters. No?
If this were a web page, the dropdownlist binding would look something like
this:
ddlSeller.DataSource = dsPrepaid.Tables["Seller"];
ddlSeller.DataTextField = "Name";
ddlSeller.DataValueField = "NameID"; <-- change appropriately
ddlSeller.DataBind()
' optional...
ddlSeller.Items.Insert(0, New ListItem("-select a Name-", ""))
If it is a combobox on winform, then:
cboSeller.DataSource = dsPrepaid.Tables["Seller"];
cboSeller.DisplayMember = "Name"
cboSeller.ValueMember = "NameID"; <-- change appropriately
Personally, considering all the troubles I've had databinding with winforms
(selectedindex=-1 issues, bound controls on tabcontrols, etc.) I prefer to
just iterate the datatable and manually add the items. But that's just me.
my .02
Greg
Greg
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... John,
A change is in my opinion that "Name" is in the wrong case or even not in your select..
That because you use three words cbo (combobox) and DropDown.
When cbo is a webpage dropdownlist than it is easy. You miss cboSeller.DataBind();
I hope this helps?
Cor
Greg,
I saw that afterwards the same as you, that it could not be a webform
because that the dropdownlist has not a displaymember.
However than had John already sent a message replying you, I replied that
and after that he came with the answer that is was a case situation.
However I am still not sure if it was the case situation here or the wrong
itemname.
However the "case" is important in this situation (I have seen this to often
in this newsgroup while it is as well my own expirience). And the strange is
with that that SQL is case insensitive.
However just as far as I know.
Cor
Hmm.
I too was confused about winform and webform. :)
I thought you were onto something with the reserved word thing. And the strange is with that that SQL is case insensitive.
"In SQL Server, object names can be case-sensitive, depending on the
character sort order that is installed. The sort order is chosen in SQL
Server Setup during installation. The default sort order in SQL Server
is dictionary order, case-insensitive.
If you need to change sort orders after installation, you must rebuild
your databases and reload your data."
John, try typing "execute sp_helpsort "in Query Analyzer to see what the
sort order and case-sensitivity is of your server. I know I am curious. :)
Greg
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl... Greg,
I saw that afterwards the same as you, that it could not be a webform because that the dropdownlist has not a displaymember.
However than had John already sent a message replying you, I replied that and after that he came with the answer that is was a case situation.
However I am still not sure if it was the case situation here or the wrong itemname.
However the "case" is important in this situation (I have seen this to often in this newsgroup while it is as well my own expirience). And the strange is with that that SQL is case insensitive.
However just as far as I know.
Cor
I'm pretty certain it was the case. The name, otherwise, DID match the
database.
I suppose the case sensitvity makes sense regardless of SQL's view since
once we get it from the database, it's no longer got anything to do with SQL
and is instead up to .NET's interpretation.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl... Greg,
I saw that afterwards the same as you, that it could not be a webform because that the dropdownlist has not a displaymember.
However than had John already sent a message replying you, I replied that and after that he came with the answer that is was a case situation.
However I am still not sure if it was the case situation here or the wrong itemname.
However the "case" is important in this situation (I have seen this to
often in this newsgroup while it is as well my own expirience). And the strange
is with that that SQL is case insensitive.
However just as far as I know.
Cor
Sorry, I had been silly in my editing. The actual field name was
"EntityName"--which is what I was using on the .NET side as well...
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uI**************@TK2MSFTNGP12.phx.gbl... John,
Always the same problem and than I forgot it. You cannot use reserved SQL words as items and AFAIK is "Name" one of them.
Cor
My database is VFP, so I don't have the sp_help option. In VFP, object
names are always case-insensitive. I suppose it's possible that MSSQL could
cause a variation depending on how it's sensitivity was configured, but I'm
still thinking it's based on .NET's handling of the stream it gets from the
database--whatever flavor that may be.
It is a bit funny to me that a typed data set doesn't have to match case,
but the rest of it seems to.
Is it C#, perhaps? I just don't remember, but I was thinking that VB is
less rabid about its case handling.
- John
Oh and just to be clear, it is a WinForm I'm working on.
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:O7**************@tk2msftngp13.phx.gbl... Hmm.
I too was confused about winform and webform. :)
I thought you were onto something with the reserved word thing.
And the strange is with that that SQL is case insensitive. "In SQL Server, object names can be case-sensitive, depending on the character sort order that is installed. The sort order is chosen in SQL Server Setup during installation. The default sort order in SQL Server is dictionary order, case-insensitive.
If you need to change sort orders after installation, you must rebuild your databases and reload your data."
John, try typing "execute sp_helpsort "in Query Analyzer to see what the sort order and case-sensitivity is of your server. I know I am curious.
:) Greg
"Cor Ligthert" <no************@planet.nl> wrote in message news:uD**************@TK2MSFTNGP12.phx.gbl... Greg,
I saw that afterwards the same as you, that it could not be a webform because that the dropdownlist has not a displaymember.
However than had John already sent a message replying you, I replied
that and after that he came with the answer that is was a case situation.
However I am still not sure if it was the case situation here or the
wrong itemname.
However the "case" is important in this situation (I have seen this to often in this newsgroup while it is as well my own expirience). And the strange is with that that SQL is case insensitive.
However just as far as I know.
Cor
I think you are right about it not mattering once you get it from the
database. It will matter if and when you try and write it back (if the
server is case-sensitive).
But... by not mattering I mean case-insensitive. Datatables etc are not
case-sensitive. Plus I just tried it to be sure! :)
Greg
"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... I'm pretty certain it was the case. The name, otherwise, DID match the database.
I suppose the case sensitvity makes sense regardless of SQL's view since once we get it from the database, it's no longer got anything to do with SQL and is instead up to .NET's interpretation.
"Cor Ligthert" <no************@planet.nl> wrote in message news:uD**************@TK2MSFTNGP12.phx.gbl... Greg,
I saw that afterwards the same as you, that it could not be a webform because that the dropdownlist has not a displaymember.
However than had John already sent a message replying you, I replied that and after that he came with the answer that is was a case situation.
However I am still not sure if it was the case situation here or the wrong itemname.
However the "case" is important in this situation (I have seen this to often in this newsgroup while it is as well my own expirience). And the strange is with that that SQL is case insensitive.
However just as far as I know.
Cor
> My database is VFP
:)
I been making too many assumptions. Sorry.
I would think a typed dataset in C# would definately be case sensitive, and
not so in VB. Afterall, a typed dataset is just a class. But I am not sure
how the rules apply when it comes to setting DisplayMember properites, etc.
Greg
"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:Oj**************@TK2MSFTNGP14.phx.gbl... My database is VFP, so I don't have the sp_help option. In VFP, object names are always case-insensitive. I suppose it's possible that MSSQL could cause a variation depending on how it's sensitivity was configured, but I'm still thinking it's based on .NET's handling of the stream it gets from the database--whatever flavor that may be.
It is a bit funny to me that a typed data set doesn't have to match case, but the rest of it seems to.
Is it C#, perhaps? I just don't remember, but I was thinking that VB is less rabid about its case handling.
- John
Oh and just to be clear, it is a WinForm I'm working on.
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message news:O7**************@tk2msftngp13.phx.gbl... Hmm.
I too was confused about winform and webform. :)
I thought you were onto something with the reserved word thing.
>And the strange is with that that SQL is case insensitive.
"In SQL Server, object names can be case-sensitive, depending on the character sort order that is installed. The sort order is chosen in SQL Server Setup during installation. The default sort order in SQL Server is dictionary order, case-insensitive.
If you need to change sort orders after installation, you must rebuild your databases and reload your data."
John, try typing "execute sp_helpsort "in Query Analyzer to see what the sort order and case-sensitivity is of your server. I know I am curious. :) Greg
"Cor Ligthert" <no************@planet.nl> wrote in message news:uD**************@TK2MSFTNGP12.phx.gbl... > Greg, > > I saw that afterwards the same as you, that it could not be a webform > because that the dropdownlist has not a displaymember. > > However than had John already sent a message replying you, I replied that > and after that he came with the answer that is was a case situation. > > However I am still not sure if it was the case situation here or the wrong > itemname. > > However the "case" is important in this situation (I have seen this to > often in this newsgroup while it is as well my own expirience). And the > strange is with that that SQL is case insensitive. > > However just as far as I know. > > Cor > >
Greg,
I tried that than as you probably almost suspected of course as well.
\\\only two comboboxes on a form.
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Greg")
For i As Integer = 0 To 9
Dim dr As DataRow = dt.NewRow
dr(0) = i.ToString
dt.Rows.Add(dr)
Next
ComboBox1.DataSource = dt
ComboBox2.DataSource = dt
ComboBox1.DisplayMember = "Greg"
ComboBox1.DisplayMember = "greg"
End Sub
///
Combobox1 shows a table from zero to 9
Combobox2 shows a for me a table with 10 times
System.Data.DataRowView
Can you try it as well to see if we have different systems?
Cor
"Greg Burns"
Greg,
Of course with a forgotten
:-)
Cor
My jaw has just hit the floor. You are (again) correct Cor.
I am seeing the same results, even when pulling from SQL (code below).
(My previous test was not actually using databinding afterall, sorry about
that)
It does appear to be case sensitive after reaching the datatable!
Since I have NEVER seen this before, I assume this is only case sensitive
when using DisplayMember and ValueMember??? (I rarely use databinding,
don't get me started) Accessing column data from the rows collection is not
case sensitive, is it?
I have never ran into this with webforms either and I use databinding with
DataTextField and DataValueField all the time. Do the same case-sensitivity
rules apply???
Greg
Dim cn As New SqlConnection("data source=.;initial
catalog=northwind;integrated security=SSPI;persist security
info=False;packet size=4096;")
'Dim cmd As New SqlCommand("SELECT CompanyName FROM shippers", cn)
Dim cmd As New SqlCommand("SELECT companyname FROM shippers", cn)
Dim dt As New DataTable
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt)
ComboBox1.DataSource = dt
ComboBox2.DataSource = dt
ComboBox1.DisplayMember = "CompanyName"
ComboBox2.DisplayMember = "companyname"
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Greg,
I tried that than as you probably almost suspected of course as well.
\\\only two comboboxes on a form. Private Sub Form1_Load(ByVal sender _ As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As New DataTable dt.Columns.Add("Greg") For i As Integer = 0 To 9 Dim dr As DataRow = dt.NewRow dr(0) = i.ToString dt.Rows.Add(dr) Next ComboBox1.DataSource = dt ComboBox2.DataSource = dt ComboBox1.DisplayMember = "Greg" ComboBox1.DisplayMember = "greg" End Sub /// Combobox1 shows a table from zero to 9 Combobox2 shows a for me a table with 10 times System.Data.DataRowView
Can you try it as well to see if we have different systems?
Cor
"Greg Burns"
Greg, I have never ran into this with webforms either and I use databinding with DataTextField and DataValueField all the time. Do the same case-sensitivity rules apply???
You mean this one.
textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"LastName"))
Without testing now and AFAIK, Yes
Cor
> You mean this one. textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0), "LastName"))
Nah, I mean binding a DropDownList in a webform...
ddlWeek.DataSource = eTime.ApproveWeeksDB.GetApproveWeeks
ddlWeek.DataTextField = "range" ' works either way "range" or "Range" or
"rAnGe"
ddlWeek.DataValueField = "WeekEnd"
ddlWeek.DataBind()
Does not seems to be case sensitive at all here. I am sure it is probably
an entirely different architecture behind the scenes (winform databinding
versus webform databinding). Well, at least as far as binding a web
DropDownList compared to a winform ComboBox goes.
Greg
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uZ**************@TK2MSFTNGP14.phx.gbl... Greg,
I have never ran into this with webforms either and I use databinding with DataTextField and DataValueField all the time. Do the same case-sensitivity rules apply???
You mean this one. textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0), "LastName"))
Without testing now and AFAIK, Yes
Cor
Greg,
I try it probably tomorrow.
I have only to copy the code for that
:-)
OK?
Cor
Greg,
You are right as well about the webpage, I tested it, I saw there was a
little error in my windowform sample that you corrected in your test.
Therefore I show both samples now.
The Windowform sample in VBNet which "has to" be case sensitive and
therefore goes wrong and a webform sample in C# which maybe case insensitive
and therefore goes right.
\\\VBNet case sensitive windowform needs 2 comboboxes on a form
Private Sub Form11_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Greg")
For i As Integer = 0 To 9
Dim dr As DataRow = dt.NewRow
dr(0) = i.ToString
dt.Rows.Add(dr)
Next
ComboBox1.DataSource = dt
ComboBox2.DataSource = dt
ComboBox1.DisplayMember = "Greg"
ComboBox2.DisplayMember = "greg"
End Sub
///
\\\Case insensitive C# needs 2 dropdownlists on a form
private void Page_Load(object sender, System.EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Greg");
for (int i = 0; i < 10;i++)
{
DataRow dr = dt.NewRow();
dr[0] = i.ToString();
dt.Rows.Add(dr);
}
DropDownList1.DataSource = dt;
DropDownList2.DataSource = dt;
DropDownList1.DataTextField = "Greg";
DropDownList2.DataTextField = "greg";
DropDownList1.DataBind();
DropDownList2.DataBind();
}
///
Real weird is it not?
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alvaro E. Gonzalez V. |
last post by:
Hello!!!
I'm building a control that in a property
assign a Dataset which they are initialized and another property Like
DataMember.
Similar as it happens to the DataSource property of a...
|
by: Kris Rockwell |
last post by:
Hello,
I have done the following to bind data to a DropDown box:
1. Drag SQLServer table onto web form to create data connection and data
adapter.
2. Generate dataset by right-clicking on...
|
by: Pietje puk |
last post by:
Hello,
Since im quite new to ASP.NET i wanted to ask you folks what the best
way is to create a WebForm for modifying 1 field from a record. The
manipulation of this field can be done by using...
|
by: John Spiegel |
last post by:
Hi all,
I think I've stared at it until it's made me stupid(er?). What am I missing
about setting the list of the dropdown to display data pulled from a table?
//......
|
by: Chris |
last post by:
Hi,
I have a button on a form, that opens a second form where I'm cloning
a usercontrol, something akin to Access' continuous forms. Now, in
this usercontrol I have a couple comboboxes. Now I...
|
by: Wingot |
last post by:
Hey,
I have a program I am trying to write using Visual C#, SQL Server
2005/2008, and Visual Studio 2008, and one part of it includes a Schema
called Client. Inside this schema, three tables...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |