hi i am binding a combobox from source code... now i want to concatenate it with an other database column with same table.... my source code is.... :
<div class="dnnFormItem">
<dnn:Label ResourceKey="LBLEmpId" Text="Name:" runat="server" id="dlbEmpId" ControlName="ddlEmpId" />
<asp:DropDownList ID="ddlEmpId" DataTextField="FName" DataValueField="Id" runat="server"/>
</div>
Here my "DataTextField="FName" but i want to display First name + Last name "DataTextField="FName + LName"... and my C# code is:
`public void ddlEmpIdbind()
{
this.ddlEmpId.DataSource = new DocEmpProfile.DocEmpProfileController().GetAll(this.PortalId);
this.ddlEmpId.DataBind();
ListItem li = new ListItem();
li.Text = "Select Employee";
li.Value = "-1";
li.Selected = true;
this.ddlEmpId.Items.Insert(0, li);
} `
Create a read-only property on your domain object, something like:
public string FullName {
get {
return string.format("{0} {1}", this.FName, this.LName);
}
}
and bind that to your combobox DataTextField property. Consider doing this in a partial class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.