This is a migrated thread and some comments may be shown as answers.

Combobox is not populating list of items on load

1 Answer 90 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 13 Apr 2016, 04:57 PM

 

ascx design 

<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="ucAddtionalConditions.ascx.cs" Inherits="ClientPortal.FNFConnect.Web.UI.Controls.Submit.ucAddtionalConditions" %>
<%@ Register Assembly="GtCustomWebControlLibrary" Namespace="Gryphtech.Translation.Web.UI.WebControls" TagPrefix="cc1" %>


<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

        <style type="text/css">
            .style1
            {
                width: 125px;
            }
        </style>
<cc1:GtTranslationManager ID="ucAdditionalConditions_CustomManager" 
runat="server" TranslationGroupId="294604c7-0340-4ffd-81b9-cf62c47f1b53">
</cc1:GtTranslationManager>

<div class="webPartControl">
    <h4>
           <cc1:GtTranslatableLabel ID="lblHeader" runat="server" 
                    TranslationItemId="9131ec56-4b3f-4fd1-b7a5-4a88bdff2a7a" 
                    TranslationManagerId="ucAdditionalConditions_CustomManager">ADDITIONAL 
                CONDITIONS</cc1:GtTranslatableLabel>
                </h4>
    <div class="webPartControlContents">
        <table class="controlTable">
            <tr id="tdAddCondition" runat="server">
                <td class="divLine widthMedium">
                    <cc1:GtTranslatableLabel ID="lblAddConditions" runat="server" 
                        TranslationItemId="017b75f2-4811-4ba6-ba46-de63e71e1903" 
                        TranslationManagerId="ucAdditionalConditions_CustomManager">Add 
                    Condition(s):</cc1:GtTranslatableLabel>
                    &nbsp;
                </td>
                <td class="divLine" style="width: 70%">
                  <telerik:RadComboBox runat="server" ID="ddlConditions" ExpandDirection="Up" Width ="98%" MaxHeight="250">
                    </telerik:RadComboBox>
                </td>

                <td class="divLine">
                   <a class="roundButton" onclick="copyCondition()" type="button"><span><% = lblAdd.Text %></span></a>
                </td>
            </tr>
            <tr>
               <td class="divLineLast widthMedium">
                    &nbsp;
                </td>
                <td class="divLineLast" style="width: 70%">
                    <asp:TextBox ID="txtCondition" runat="server" Height="250px" 
                        TextMode="MultiLine" Width="97%"></asp:TextBox>
                </td>
                <td class="divLineLast">
                    <a id="lnkClear" runat="server" onclick="clearConditions()" type="button" class="roundButton"><span><% = lblClear.Text %></span></a>&nbsp;
                </td>
            </tr>
        </table>
    </div>
</div>
        <script type="text/javascript">
            function copyCondition()
            {
                var ddl = $find('<% = ddlConditions.ClientID %>');
                if (ddl.get_selectedIndex() > 0)
                {
                    var textBox = $get('<% = this.txtCondition.ClientID %>');
                    if (textBox.value == '')
                        textBox.value = '- ' + ddl.get_selectedItem().get_value();
                    else
                        textBox.value += '\r' + '- ' + ddl.get_selectedItem().get_value();
                    
                    ddl.selectedIndex = 0;
                }
            }
        
            function clearConditions()
            {
                $get('<% = this.txtCondition.ClientID %>').value = '';
                var ddl = $find('<% = ddlConditions.ClientID %>');
                ddl.get_items().getItem(0).select();
            }
        </script>
<cc1:GTTranslatableEditPanel ID="ucAddtionalConditions_CustomEdit" 
    runat="server" TranslationManagerId="ucAdditionalConditions_CustomManager">
    <cc1:GtTranslatableLabel ID="lblClear" runat="server" 
        TranslationItemId="f25a42ae-784b-44ba-878c-8fece4df0b48" 
        TranslationManagerId="ucAdditionalConditions_CustomManager">
        Clear
    </cc1:GtTranslatableLabel>
    <br />
    <cc1:GtTranslatableLabel ID="lblAdd" runat="server" 
        TranslationItemId="e62442e9-9b30-46ac-8080-2a8da22ecbda" 
        TranslationManagerId="ucAdditionalConditions_CustomManager">
        Add
    </cc1:GtTranslatableLabel>
</cc1:GTTranslatableEditPanel>

 

c# server side code

 

using System;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using ClientPortal.Web.UI;
using FNF.CP.Data;
using Telerik.Web.UI;


namespace ClientPortal.FNFConnect.Web.UI.Controls.Submit
{
    public partial class ucAddtionalConditions : PortalBaseSubmitControl, IsubmitLoadNPSProvider
    {
        #region PageEvents
        protected void Page_Load(object sender, EventArgs e)
        {
            ddlConditions.DataBinding += new EventHandler(ddlConditions_DataBinding);

            ddlConditions.DataBound += delegate
            {
                //Hide dropdown + Add button if table used to populate drop-down list is empty
                if (ddlConditions.Items.Count == 1)
                {
                    tdAddCondition.Visible = false;
                    lnkClear.Visible = false;
                }
            };

            if (!Page.IsPostBack)
            {
                ddlConditions.DataBind();
            }
        }
        #endregion

        #region Binding

        void ddlConditions_DataBinding(object sender, EventArgs e)
        {
            ddlConditions.AppendDataBoundItems = true;
            ddlConditions.Items.Clear();
            ddlConditions.DataSource = FNF.CP.Data.AdditionalConditionsDB.getAdditionalConditions(ucAdditionalConditions_CustomManager.Language.LanguageCode);
            ddlConditions.DataValueField = "conditionName";
            ddlConditions.DataTextField = "conditionName";

            ddlConditions.Items.Insert(0, new RadComboBoxItem(string.Empty));

        }

        #endregion

        #region IsubmitLoadNPSProvider Members

        public void fillProvider(ref FNF.NPSWS.fnfnpsBodyRequest request, ref FNF.SOA.Appraisals.AppraisalBodyRequest aRequest)
        {
            string condition = txtCondition.Text.Trim();
            if (request == null || condition.Length == 0)
                return;

            StringBuilder sb = new StringBuilder();
            if (condition.Contains(Environment.NewLine))
            {
                sb.Append("<ul style='list-style-type:normal'>");
                foreach (string item in condition.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    sb.Append("<li>").Append(item.TrimStart(new char[] { '-', ' ' })).Append("</li>");
                }
                sb.Append("</ul>");
            }
            else
            {
                sb.Append(condition);
            }

            request.Conditions = new string[1] { sb.ToString() };
        }

        public void loadSubmitData(ConnectFile file)
        {
            // no implementation yet
        }

        #endregion
    }
}

 

 

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 18 Apr 2016, 02:16 PM
Hello Rahul,

I am afraid that I was unable to locally replicate the described issue, due to some missing references. Especially the getAdditionalConditions method which is responsible for data supply for the RadComboBox.

This is why, I would like to ask you to submit a support ticket, along with a runnable sample attached, where the experienced issue is replicable. Thus, we will be able to locally replicate the problem and suggest you the proper approach.

Regards,
Nencho
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ComboBox
Asked by
Rahul
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or