c# - How to add third value in asp.net dropdownlist item? -


i adding profile names list 1 (profile column) , list 2(profile column) asp.net dropdownlist control. when user click on profile in dropdown, should identify if selected profile belongs list 1 or list 2. can suggest ?

using (spsite site = new spsite("my site url"))             {                 using (spweb web = site.openweb())                 {                     spquery query = new spquery();                     string username = spcontext.current.web.currentuser.tostring();                     username = username.substring(username.lastindexof("\\") + 1);                     splist listconfig = web.lists.trygetlist("searchconfig");                     query.query = "<where><eq><fieldref name='login_x0020_user' /><value type='text'>" + username + "</value></eq></where>";                     splistitemcollection items = listconfig.getitems(query);                     datatable dtadminprofile = items.getdatatable();                      dropdownlist1.datasource = dtadminprofile;                     dropdownlist1.datatextfield = "profile_x0020_name";                     dropdownlist1.datavaluefield = "profile_x0020_name";                     dropdownlist1.databind();                  }             } 

thanks, chintan

if there condition available through can identify profile type can use optiongroup below:

foreach (datarow dr in dtadminprofile) {      listitem item = new listitem(convert.tostring(dr["profile_x0020_name"]), convert.tostring(dr["profile_x0020_name"]));       if(somecondition)      {           item.attributes["optiongroup"] = "list 1";      }      else      {           item.attributes["optiongroup"] = "list 2";      }       dropdownlist1.items.add(item1); } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -