set your DropDownList to a specified value


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

usage:
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. }

URL: http://naspinski.net/post/Simplify-setting-your-DropDownLists-to-a-specific-value.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.