4 Replies - 1555 Views - Last Post: 08 August 2013 - 09:05 AM Rate Topic: -----

#1 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 497
  • View blog
  • Posts: 3,315
  • Joined: 12-January 10

quick question on how to reset the selected values

Posted 07 August 2013 - 12:13 PM

so i have a select box as follows:

<select id="other_file_type" name="other_file_type" runat="server">
                <option value=""></option>
                <option value="W-9">W-9</option>
                <option value="Resume">Resume</option>
                <option value="Misc">Misc</option>
            </select>


vb.net side
other_files_selected = other_file_type.Value


i have tried the following to reset the field in the load

 other_file_type.Value = ""




but when i do the select the code only shows the 1st element of ""
if i remove the blank space from the list it only shows w-9


am i missing something?

Is This A Good Question/Topic? 0
  • +

Replies To: quick question on how to reset the selected values

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 294
  • View blog
  • Posts: 1,532
  • Joined: 07-April 08

Re: quick question on how to reset the selected values

Posted 07 August 2013 - 01:09 PM

why are you using a select with runat="server"? why not use an asp:dropdownlist and set the selectedindex = 0 to reset it, alternatively you should be able to do something like this:

'NOTE:  I have not tested this, but it should do what you want.
dim li as ListItem = other_file_type.Items.FindByValue("")
li.Selected = true



EDIT:
So I've tested the above and it will do what you want it to do, the only addition you will need to make is to set the currently selected item's selected property to false before setting the new one to true.

This post has been edited by rgfirefly24: 07 August 2013 - 02:07 PM

Was This Post Helpful? 0
  • +
  • -

#3 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 497
  • View blog
  • Posts: 3,315
  • Joined: 12-January 10

Re: quick question on how to reset the selected values

Posted 07 August 2013 - 01:36 PM

I was trying to keep in line with the code we already have but ill try yours out tomorrow...
Was This Post Helpful? 0
  • +
  • -

#4 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 294
  • View blog
  • Posts: 1,532
  • Joined: 07-April 08

Re: quick question on how to reset the selected values

Posted 07 August 2013 - 02:08 PM

The code i showed you will keep inline with what you have. It takes the HTML select element and resets the selected value of it to the empty option.
Was This Post Helpful? 0
  • +
  • -

#5 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 497
  • View blog
  • Posts: 3,315
  • Joined: 12-January 10

Re: quick question on how to reset the selected values

Posted 08 August 2013 - 09:05 AM

the "runat" was what was causing the problem. I eliminated that and everything is working now.

Thanks rg
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1