unable to set text to radcombobox in radgrid itemtemplate

2 posts, 1 answers
  1. Chinna
    Chinna avatar
    9 posts
    Member since:
    Feb 2011

    Posted 09 Mar 2011 Link to this post

    hi,

    trying to set text to radcombobox in radgrid itemtemplate and getting error "object reference not set an instance of an object"

    aspx:

    <

     

    telerik:GridTemplateColumn HeaderText = "Print Letters/Post Cards" UniqueName = "PrintLetter" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign

    ="Center">

     

     

     

    <ItemTemplate

    >

     

     

     

    <telerik:RadComboBox ID= "Print" runat

    ="server">

     

     

     

    <Items

    >

     

     

     

    <telerik:RadComboBoxItem runat="server" Text

    ="1 Year Postcard"/>

     

     

     

    <telerik:RadComboBoxItem runat="server" Text

    ="1 Year Adult"/>

     

     

     

    <telerik:RadComboBoxItem runat="server" Text

    ="2 Years Adult"/>

     

     

     

    <telerik:RadComboBoxItem runat="server" Text

    ="3 Year"/>

     

     

     

    </Items

    >

     

     

     

    </telerik:RadComboBox

    >

     

     

     

    </ItemTemplate

    >

     

     

    </

     

    telerik:GridTemplateColumn

    >

     

     


    aspx.cs:

     

    protected void ItemDataBound(object sender, GridItemEventArgs

    e)

     

     

    {

     

     

     

    GridDataItem dataItem = e.Item as GridDataItem

    ;

     

     

     

     

    RadComboBox Print = ((RadComboBox)dataItem["PrintLetter"].FindControl("Print"

    ));

     

     

    Print.Text =

    "1year"

    ;

     

     

    }

     


    Please suggest me on this.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Mar 2011 Link to this post

    Hello Chinna,


    If you need to set custom text for RadComboBox, then you will have to set the AllowCustomText property of the control to True.

    <ItemTemplate>
            <telerik:RadComboBox AllowCustomText="true" ID="Print" runat="server">
                    <Items>



    -Shinu.
Back to Top