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

RadComboBox ItemTemplate not binding

5 Answers 400 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 16 Feb 2012, 08:54 AM

Hi,

I have a RadComboBox with a Header and Item Templates. I have set the EnableLoadOnDemand to true and using the OnItemsRequested event to populate the ComboBox. In the event am getting the values in a DataSet and using it as the datasource and binding it to the ComboBox using DataBind() method. But the data is not getting displayed and in the UI it is just showing the message as "Loading...". Am not even getting any exceptions and the datasource is being assigned properly. Am I missing something else?. Please help me in this regard. Thanks.

Below are the aspx and the script CS code i have written. Please find the attached screenshot as well.

<script type="text/C#" language="CS" runat="server">
        protected void RadComboBox_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            try
            {
                SomeClass sclass = new SomeClass()
                DataSet ds = sclass.SomeMethod();
                RadComboBox rcb = (RadComboBox)sender;
                rcb.DataSource = ds;
                rcb.DataTextField = "Column1";
                rcb.DataValueField = "Column0";
                rcb.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
</script>

 

<telerik:RadComboBox HighlightTemplatedItems="true" IsCaseSensitive="false" ID="ddlRadComboBox1" EnableLoadOnDemand="true" runat="server" TabIndex="9"  OnItemsRequested="RadComboBox_ItemsRequested" style="width:30%;height:25px;" DropDownWidth="750">
                     <HeaderTemplate>
                                <table style="width: 750px; font-family:Verdana; font-size:11px;" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td style="width:35%;">Column 1</td>
                                        <td style="width:65%;">Column 2</td>
                                    </tr>
                                </table>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <table style="width: 750px; font-family:Verdana; font-size:11px;" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td style="width:35%;"><%# DataBinder.Eval(Container.DataItem, "Column1")%></td>
                                        <td style="width:65%;"><%# DataBinder.Eval(Container.DataItem, "Columns2")%></td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </telerik:RadComboBox>

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Feb 2012, 09:40 AM
Hello,

Here is the sample code I tried and worked as expected.
ASPX:
<ItemTemplate>
  <table>
     <tr>
      <td>
        <%# DataBinder.Eval(Container.DataItem, "FirstName")%>
      </td>
      <td>
        <%# DataBinder.Eval(Container.DataItem, "EmployeeID")%>
      </td>
     </tr>
  </table>
</ItemTemplate>

C#:
public void combo_onitemRequested(object o,RadComboBoxItemsRequestedEventArgs e)
  {
        String str = System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(str);
        String command = "SELECT EmployeeID, FirstName FROM Employees";
        SqlDataAdapter ad = new SqlDataAdapter(command, con);
        DataSet dt = new DataSet();
        ad.Fill(dt);
        RadCombobox1.DataTextField = "FirstName";
        RadCombobox1.DataValueField = "EmployeeID";
        RadCombobox1.DataSource = dt;
        RadCombobox1.DataBind();
  }

Thanks,
Princy.
0
Sandeep
Top achievements
Rank 1
answered on 17 Feb 2012, 05:26 AM
Hi Princy,

Thanks for your kind reply. Even I tried the same creating a different project. It worked fine as expected. But the same isn't working in my base project. Not sure if I am missing anything.

Regards,Sandeep
0
Dimitar Terziev
Telerik team
answered on 21 Feb 2012, 12:01 PM
Hi Sandeep,

In case you're experiencing this problem only on one of your projects than it might be some configuration issue. Could you provide more information about this problematic project? Which .Net framework you are using, is the page with the RadComboBox a default one and also is the server-side event ItemsRequested fired?

Kind regards,
Dimitar Terziev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Sandeep
Top achievements
Rank 1
answered on 23 Feb 2012, 11:31 AM
Hi Dimitar,

I am working on .Net framework 3.5 and yes the page with the RadComboBox is a default one. The server-side ItemsRequested event also gets fired properly as expected. The data also is fetched correctly into the dataset. There are no exceptions/ errors while assigning the datasource as well.

Regards,
Sandeep
0
Dimitar Terziev
Telerik team
answered on 24 Feb 2012, 02:04 PM
Hello Sandeep,

In order to further troubleshoot this issue, please open a support ticket and provide a runnable version of your project so we could debug and test it locally.

Greetings,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sandeep
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or