Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is my server side code:
C#
private void AddLeaveTypeCodeToDDl()
   {
       ddlLeaveTypeCode.Items.Add(new ListItem("", "0"));
       ddlLeaveTypeCode.DataSourceID = string.Empty;
       ddlLeaveTypeCode.DataSource = fetchData.NAVLeaveTypeList();
       ddlLeaveTypeCode.DataBind();
   }


this is my client side code:::
XML
<asp:DropDownList ID="ddlLeaveTypeCode" runat="server" DataTextField="Leave_Type_Code"
                            DataValueField="Key" AutoPostBack="True" OnSelectedIndexChanged="ddlLeaveTypeCode_SelectedIndexChanged"
                            AppendDataBoundItems="True" Width="184px">
                        </asp:DropDownList>


currently only Leave_Type_Code is shown on ddlLeaveTypeCode. the current format is " AL " .. but i wanted Description to be added along with leavetypecode. the format is like " Al - Annual Leave " here, fetchData.NAVLeaveTypeList() returns array of records.. how can i do it!!!
Posted
Comments
AndrewCharlz 11-Mar-14 5:25am    
when u create a list join two column into one and this way u can do

1 solution

Try this

C#
ddlLeaveTypeCode.Items.Add(new ListItem("", "0"));
            var data  = fetchData.NAVLeaveTypeList();
            for (int i = 0; i < data.Length; i++)
            {
                var item = data[i];
                ddlLeaveTypeCode.Items.Add(new ListItem() { Text = item.Leave_Type_Code + "-" + item.Description, Value = item.Key });
            }

let me know if you face any issues...
 
Share this answer
 
Comments
Codes DeCodes 11-Mar-14 20:13pm    
sure karthik.
Codes DeCodes 13-Mar-14 6:26am    
thanks karthik.. it worked..
Karthik_Mahalingam 14-Mar-14 4:53am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900