RadcomboBox in Sharepoint codebehind

2 posts, 0 answers
  1. SANNIDHI
    SANNIDHI avatar
    24 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    Hi,

    In Sharepoint aspx page i have dropdown and radcombobox controls.

    When i try to fill radcombobox and asp:dropdownlist controls from the code behind file, only asp:dropdownlist is getting filled.
    I am unable to fill radcombobox or any other rad controls in the codebehind file.

    I double checked radcontrols id's in the aspx and in the code behind. There is no mismatch in the ID names.
    Still only all my rad controls are null in the code behind. (asp.net controls i am able to access in the same code behind file)

    Similar problem was found in one of the telerik forums  http://www.telerik.com/community/forums/aspnet-ajax/ajax/radlistbox-and-sharepoint-code-behind-project.aspx.

    Pleass help me to resolve this issue.

    //Code Behind File
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    using System.Web.UI.WebControls;
    using Microsoft.SharePoint.Utilities;
    using Telerik.Web.UI;
      
    namespace SPTelerikTest 
        public partial class SPTelerikTest : System.Web.UI.Page 
        
            protected DropDownList DropDownList1; 
            protected RadComboBox RadComboBox1; 
      
            protected void Page_Load(object sender, EventArgs e) 
            
      
               if (!Page.IsPostBack) 
                
                   DropDownList1.Items.Add("Item1");
                   RadComboBoxItem oradComboBoxItem = new RadComboBoxItem("Item1);
                   RadComboBox1.Items.Add(oradComboBoxItem);
                }  
            
       }
    }
     
     
     
    //Aspx Page code snippet
     
    <table>
            <tr>
                <td>
                <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="120px" Skin="WebBlue"   EmptyMessage="Select Partner Name" ></telerik:RadComboBox>
                </td>
                <td>
                <asp:DropDownList ID="DropDownList1" runat="server" Width="120px"  >
                                        </asp:DropDownList>
     
                </td>
          </tr>
    </table>

  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 04 Jan 2011 Link to this post

    Hello SANNIDHI,

    Let me suggest you make a small change in your code:
    <table>
        <tr>
            <td>
                <telerik:RadComboBoxid="RadComboBox2"
                    runat="server"width="120px"skin="WebBlue"
                    emptymessage="Select Partner Name"
                    AllowCustomText="true"></telerik:RadComboBox>
            </td>
            <td>
                <asp:DropDownListID="DropDownList2"
                runat="server"Width="120px">
                </asp:DropDownList>
            </td>
        </tr>
    </table>
    // protected DropDownList DropDownList1;
    //  protected RadComboBox RadComboBox1;
        
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!Page.IsPostBack)
        {
            this.DropDownList1.Items.Add("Item1");
            RadComboBoxItem oradComboBoxItem = new RadComboBoxItem("Item1");
            this.RadComboBox1.Items.Add(oradComboBoxItem);
        }
    }

    (Please note that in order to display the EmptyMessage in RadComboBox input you need to set the AllowCustomText property of the control to "true".)

    I created a sample SharePoint2010 WebPart with the above code - please find it attached.

    Best wishes,
    Kalina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top