Posted By

naspinski on 01/11/09


c aspnet DropDownList

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


set your DropDownList to a specified value

 / Published in: ASP


usage: SomeDropDownList.Set("Some String Value");

  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  

You need to login to post a comment.