J
Jesper Lund Stocholm
I have a ListBox control that I bind some data to. The data is an array of
objects from a webservice. I have no way of changing the objects nor
changing the SQL "under neath" the WCF-interface I extract the objects
from.
I assign the object list to the .DataSource-property of the control and
assign the DataValue-property as well as the DataTextField-property.
But - and this I cannot seem to get my head around - I would like to
combine two fields on my object to the DataTextField-property.
It's the classic: "Display firstname as well as lastname in the ListBox".
I would think that I could accomplish this in the DataBind-event of the
control, but I cannot seem to figure out how to get the code right.
The idea was to do something like:
public void PeopleListBox_DataBind(object sender, EventArgs e)
{
// some pseudo-code:
Item.DataValueField = myObject.SocSecNumber;
Item.DataTextField = myobject.Firstname + " " + myObject.Lastname;
}
Does it make any sense?
objects from a webservice. I have no way of changing the objects nor
changing the SQL "under neath" the WCF-interface I extract the objects
from.
I assign the object list to the .DataSource-property of the control and
assign the DataValue-property as well as the DataTextField-property.
But - and this I cannot seem to get my head around - I would like to
combine two fields on my object to the DataTextField-property.
It's the classic: "Display firstname as well as lastname in the ListBox".
I would think that I could accomplish this in the DataBind-event of the
control, but I cannot seem to figure out how to get the code right.
The idea was to do something like:
public void PeopleListBox_DataBind(object sender, EventArgs e)
{
// some pseudo-code:
Item.DataValueField = myObject.SocSecNumber;
Item.DataTextField = myobject.Firstname + " " + myObject.Lastname;
}
Does it make any sense?