Each ImageMap represents a car part (Front Bumper, Rear Bumper, Mirror, Hood, Sunroof, DoorShell, Headlights, Tail lights) and I have a dropdownlist ddlChosenParts. When the user clicks on any of the 8 ImageMaps, I add the PostBackValue to the dropdownlist ddlChosenParts.
The problem is that if the user clicks on the same ImageMap twice, the PostBackValue is added twice.
I want to check if ddlChosenParts contains the ImageMap's PostBackValue and if it already contains it, do not add it again. That means that if the user clicks more than once on the same ImageMap, it's PostBackValue is only added once in ddlChosenParts.
I have this code but i'm getting an error: Value of Type String cannot be converted to ListItem. And I know why i'm getting this error but just can't seem to solve it.
Protected Sub imFrontBumper_Click(sender As Object, e As System.Web.UI.WebControls.ImageMapEventArgs) Handles imFrontBumper.Click
If ddlChosenParts.Items.Contains(e.PostBackValue) Then
lblStatus.ForeColor = Drawing.Color.Red
lblStatus.Text = " - Part '" & e.PostBackValue & "' already added"
Else
ddlChosenParts.Items.Add(e.PostBackValue)
lblStatus.ForeColor = Drawing.Color.Blue
lblStatus.Text = " - Part '" & e.PostBackValue & "' added to list of damaged parts"
End If
End Sub
This code is the same for the 8 ImageMaps.
Thank you.

New Topic/Question
Reply



MultiQuote






|