drop down menu - Get other values in datasource of a dropdownlist in asp.net -


i have connected stored procedure dropdownlist

the stored procedure has 3 values repid, repname, , repref

the dropdownlist has 2 values datatextfield , datavaluefield

i connected datatextfield repname , datavaluefield repid

i want repref too

how can that

here code

                conn.open();                  sqlcommand cmd = new sqlcommand("mysp", conn);                 sqldataadapter da = new sqldataadapter(cmd);                 cmd.commandtype = commandtype.storedprocedure;                  da.fill(dt);                 if (dt.rows.count > 0)                 {                     ddlreps.datasource = dt;                     ddlreps.datatextfield = "repname";                     ddlreps.datavaluefield = "repid";                     ddlreps.databind();                 } 

if user selected report called "cities" has id = 16

how can repref there?

use linq , add add new property on anonymous type way want format it:

var datasource = dt.select(x=> new {                  x.repid,                  x.repname,                  x.repref,                  displayfield = string.format("{0} {1}", x.repname, x.repref)              }).tolist();  ddlreps.datasource = datasource; ddlreps.datavaluefield = "repid"; ddlreps.datatextfield = "displayfield"; ddlreps.databind(); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -