c# - Combining generic lists -


right i'm combining 3 lists union. want populate gridview values, problem here in list want separate values. example:

  1. listitem [0] "firstname + " " + lastname"
  2. listitem 1 employeeid
  3. listitem [2] "second emp firstname + " " + second emp lastname"
  4. listitem [3] second emp employeeid

i want show on gridview. code @ moment:

list<string> ulist = _searchemplist.union(_searchtechskilllist).union(_searchassignlist).tolist(); string s = string.empty;  (int = 0; < ulist.count; i++) {     s += ulist[i] + ","; }  string[] split = s.split(','); datarow dr = _dt.newrow(); dr["name"] = split[0]; //firstname + +lastname dr["employeeid"] = split[1]; //employeeid  _dt.rows.add(dr);  session["datatablesearch"] = _dt;  gridviewsearchresults.datasource = _dt; gridviewsearchresults.databind(); 

enter image description here

i don't understand why you're going trouble. following want. whether it's want different question.

list<string> ulist = _searchemplist.union(_searchtechskilllist).union(_searchassignlist).tolist(); int = 0; while (i < ulist.count-1) {     datarow dr = _dt.newrow();     dr["name"] = ulist[i]; //firstname + +lastname     dr["employeeid"] = ulist[i+1]; //employeeid     _dt.rows.add(dr);     ++i; } 

that duplicates logic in original code, loop asked for. whether it's going give results think should open question. union combines 2 lists , creates new list distinct values. if there duplicate values in 2 lists, they'll show once in result.

also, union makes no guarantee order of items in final list.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -