set your DropDownList to a specified value

/ Published in: ASP
Save to your folder(s)

SomeDropDownList.Set("Some String Value");

Copy this code and paste it in your HTML
  1. public static void Set(this DropDownList ddl, string findByVal)
  2. { // attempts to set a DDL to the 'findByVal'
  3. try { ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue(findByVal)); }
  4. catch { }; // otherwise statys at the default, avoids errors
  5. }


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.