data binding - Is there a way to Append the DataTextField of a Listbox in aspx C#? -


i have data bound listbox lists names of items, wanting display both item number , item name in looks like: i-001 - item 1. have done similar this, when not using data text fields, idatareaders instead.

so can append datatextfield attribute in anyway accept more 1 column? either in aspx page or in code behind?

if there code can of can provide you, if there clearing can done best so.

thank you

sample code:

listitems.datasource = dal.util.getitemprofiles(vendor,catalog); listitems.databind();   public string itemnumname {     { return "custitemnum" + " - " + "name"; } }  protected void listitems_databound(object sender, eventargs e) {     listitems.datatextfield = itemnumname; } 

this cause following error message:

databinding: 'system.data.datarowview' not contain property name 'custitemnum - name'.

if remove + " - " + "name" property functions correctly showing custitemnum field

you edit sql concatenate 2 columns , use datatextfield. using provided variable names like:

select custitemnum, name,  custitemnum + ' - ' + name numbername 

then should able use numbername datatextfield , should display "itemnumber - itemname"


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -