/ Published in: ASP
URL: http://naspinski.net/post/Simplify-setting-your-DropDownLists-to-a-specific-value.aspx
usage: SomeDropDownList.Set("Some String Value");
Expand |
Embed | Plain Text
public static void Set(this DropDownList ddl, string findByVal) { // attempts to set a DDL to the 'findByVal' try { ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue(findByVal)); } catch { }; // otherwise statys at the default, avoids errors }
You need to login to post a comment.
