Re: DataView.Find not working with GUID
- From: "Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx>
- Date: Wed, 22 Nov 2006 05:42:26 +0100
Warren,
Some years ago I asked in some of these dotNet newsgroups why my
combobox.text was always returning the wrong items when I had binded that to
a textbox. While I was using a datasource from the combobox. (I did not know
a website for bug reporting then).
I am still waiting for the first answer, is this the sampe problem?
Cor
"Warren J. Hairston" <whairston@xxxxxxxxxxxxxxxxxxxx> schreef in bericht
news:OndDy2ZDHHA.2328@xxxxxxxxxxxxxxxxxxxxxxx
Dave,
Thanks for the reply. My code isn't returning -1. Quite the contrary -
it's just that the answer isn't correct.
To make matters more interesting, I wrote a small test program wherein I
bound the DataView to a combo box and changed my query so that only 2 rows
were returned in the DataView. I bound the combo box DisplayMember to the
JobNumber field and the ValueMember to the JobID field. When I get the
SelectedValue, it's still wrong. This is similar to what I'm doing in my
program, so I think this is where the problem really lies. I can step
through with the debugger and see the contents of the combo box, but no
matter which combo box entry I select, the SelectedValue indicates that
the other value was selected.
In the code below, JobNumber and JobName should hold the same values at
the end of execution:
... //a query to populate DV (the DataView) - debugger shows everything
is OK to this point
//cbOpenJobs is a combo box in a Windows Form - bind the DV to the combo
box
DV.Sort = "JobID";
cbOpenJobs.DataSource = DV;
cbOpenJobs.DisplayMember = "JobNumber";
cbOpenJobs.ValueMember = "JobID";
... //code below executes after the user selects a value
JobID = new Guid(cbOpenJobs.SelectedValue.ToString()); //ERROR - the
value returned is not the JobID of the record I selected from the combo
box - it's the JobID of the OTHER record!?!?
JobName = cbOpenJobs.Text; //this IS correct - the JobNumber of the
record I selected from the combo box
Offset = DV.Find(JobID);
if (Offset > -1)
{
JobNumber = DV[Offset]["JobNumber"].ToString(); //this always executes,
but because JobID was incorrect, the end result is that the wrong
JobNumber is selected here
} //JobID was located
else
{
JobNumber = "";
} //JobID was not located
//by the time we get here, JobNumber and JobName (which should hold the
same value) are different
Any insight will be greatly appreciated. Thanks in advance.
- Warren
P.S.: I was aware of the "intents and purposes" phrase - that's one of my
pet peeves. Another one that I'm seeing far too often is the phrase "I
should of done that..." for "I should've [should have] done that..." LOL -
funny how we can (usually) write working programs in other languages, but
have problems with our own. If the world was a compiler, I guess we'd
never be able to communicate because of syntax errors. :)
.
- Follow-Ups:
- Re: DataView.Find not working with GUID
- From: Warren J. Hairston
- Re: DataView.Find not working with GUID
- References:
- DataView.Find not working with GUID
- From: Warren J. Hairston
- Re: DataView.Find not working with GUID
- From: Dave Sexton
- Re: DataView.Find not working with GUID
- From: Warren J. Hairston
- Re: DataView.Find not working with GUID
- From: Dave Sexton
- Re: DataView.Find not working with GUID
- From: Dave Sexton
- Re: DataView.Find not working with GUID
- From: Warren J. Hairston
- DataView.Find not working with GUID
- Prev by Date: Re: DataView.Find not working with GUID
- Next by Date: Re: MS Access DAO -> ADO.NET Migration
- Previous by thread: Re: I Think I Found The Problem
- Next by thread: Re: DataView.Find not working with GUID
- Index(es):
Relevant Pages
|