472,951 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive (part 2)

Hi all,

I've come back to this problem again and I've identified which part of
my code is producing the error:

"'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive"
I have a dropdown 'Year' and it contains a list of years from 2000 to
2005. This dropdown is populated on page load.

When I select an article to edit (which has a year value associated), I
select the appropriate year dropdown value as follows...

ddYear.SelectedValue = objRS("VYear")
This is causing the above error, I THINK it's because the 'VYear' value
is an integer as opposed to a string.

I've also tried: ddYear.SelectedValue = CInt(objRS("VYear"))
and ddYear.SelectedValue = CStr(objRS("VYear"))

with the same error resulting.

Any ideas?

Thanks.
Peter
--

"I hear ma train a comin'
.... hear freedom comin"

Nov 19 '05 #1
5 10058
Does this work?

Dim li As ListItem = ddYear.Items.FindByValue(CStr(objRS("VYear")))
If Not li Is Nothing Then
li.Selected = True
End If

Greg
"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
Hi all,

I've come back to this problem again and I've identified which part of
my code is producing the error:

"'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive"
I have a dropdown 'Year' and it contains a list of years from 2000 to
2005. This dropdown is populated on page load.

When I select an article to edit (which has a year value associated), I
select the appropriate year dropdown value as follows...

ddYear.SelectedValue = objRS("VYear")
This is causing the above error, I THINK it's because the 'VYear' value
is an integer as opposed to a string.

I've also tried: ddYear.SelectedValue = CInt(objRS("VYear"))
and ddYear.SelectedValue = CStr(objRS("VYear"))

with the same error resulting.

Any ideas?

Thanks.
Peter
--

"I hear ma train a comin'
... hear freedom comin"

Nov 19 '05 #2
On Tue, 8 Nov 2005 Greg Burns <bl*******@newsgroups.nospam> wrote:
Does this work?

Dim li As ListItem = ddYear.Items.FindByValue(CStr(objRS("VYear")))
If Not li Is Nothing Then
li.Selected = True
End If

Greg


doesn't seem to... is there a way to set the SelectedIndex instead of
the SelectedValue if all I have is the text value?

--

"I hear ma train a comin'
.... hear freedom comin"

Nov 19 '05 #3
Put a breakpoint on "li.Selected = True". Does the debugger ever even get
there? If not, then it is not even finding that value in your current
listitems, hence cannot select it.
"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
On Tue, 8 Nov 2005 Greg Burns <bl*******@newsgroups.nospam> wrote:
Does this work?

Dim li As ListItem = ddYear.Items.FindByValue(CStr(objRS("VYear")))
If Not li Is Nothing Then
li.Selected = True
End If

Greg


doesn't seem to... is there a way to set the SelectedIndex instead of
the SelectedValue if all I have is the text value?

--

"I hear ma train a comin'
... hear freedom comin"

Nov 19 '05 #4
On Tue, 8 Nov 2005 Greg Burns <bl*******@newsgroups.nospam> wrote:
Put a breakpoint on "li.Selected = True". Does the debugger ever even get
there? If not, then it is not even finding that value in your current
listitems, hence cannot select it.


my mistake, it DOES indeed work.. the new error I was receiving was
separate to the original problem, which your code fixed.

Thanks!

It's still very unusual that you need to use this method to set the
selectedvalue when the text field in your dropdownlist is numerical
*shrug*
--

"I hear ma train a comin'
.... hear freedom comin"

Nov 19 '05 #5
Not sure I understand, but the Value and Text property of you ListItem are
both strings. You have to convert whatever object you want to be a ListItem
into a string to add it to the collection.

ddYear.Items.Insert(0, New ListItem("displayedtext", "actualvalue"))

This code insert in position 0 a new new ListItem. The constructor for
ListItem only takes strings.

To tell you the truth, I am not sure why you are having a problem with:

ddYear.SelectedValue = objRS("VYear").ToString

Greg
"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
On Tue, 8 Nov 2005 Greg Burns <bl*******@newsgroups.nospam> wrote:
Put a breakpoint on "li.Selected = True". Does the debugger ever even
get
there? If not, then it is not even finding that value in your current
listitems, hence cannot select it.


my mistake, it DOES indeed work.. the new error I was receiving was
separate to the original problem, which your code fixed.

Thanks!

It's still very unusual that you need to use this method to set the
selectedvalue when the text field in your dropdownlist is numerical
*shrug*
--

"I hear ma train a comin'
... hear freedom comin"

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: wooks | last post by:
I have defined a schema with an xsd:choice element for 2 mutually exclusive fields. When both are present I get an error which is good, but what is not so good is the error message which says...
1
by: Tony | last post by:
How do I to define a tag wit two attributes that are mutually exclusive? So I want the tag to look like this: <COM:description choice1="blah"> or <COM:description choice2="blahblah"> BUT...
0
by: jac | last post by:
Hey, this.CmbDataSource = SoortKwijtingList.Items; // Arraylist this.Cmb.DisplayMember = "Omschrijving"; this.Cmb.ValueMember = "Id"; this.Cmb.SelectedIndex = -1; (short description : I...
4
by: Emil | last post by:
Can somebody tell me what would be the syntax for having an if statement and setting the selected index of a radiobuttonlist? This is my first project using ASP.net and I use C#. I have a repeater...
2
by: Stimp | last post by:
I'm getting the error: 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive when I try to populate a series of dropdowns... any idea what I could be doing wrong here? ...
2
by: arun | last post by:
Hi Can any one suggest me how to access the mutually exclusive check box extender in a table of 7 rows by 14 columns. Only one can be selected in each row. Other than checking each one with if...
4
by: Dooman | last post by:
Hello, I am getting this error when binding a drop down list box to a dataset: The 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive I have looked at other posts and...
1
by: marcbb | last post by:
Hi all, I have a really strange problem working with Dropdownlists in a DataGrid. I'm trying to preselect some values from the DropDownlist for each row in the DataGrid, but it seems that...
0
by: katmagic | last post by:
I have the selectedindex of a gridview, but no value. How do I set the selectedvalue of a gridview? My scenario: I have 3 gridviews on a page, all of which use the same insert record control. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.