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

[Solved] Combo box text over written

1 Answer 78 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 25 Nov 2009, 10:28 PM
Hi,
 I have telerik 2009 and I m binding combo box to database . i want the text of the input field of Telerik RadComboBox to be empty when the page is loaded . But the issue is I get the text value of the checkbox's first list item in the input field of Telerik RadComboBox.

      <telerik:RadComboBox runat="server" ID="rcbLocation" HighlightTemplatedItems="true" DataTextField="Location" DataValueField="Location" Width="405px" AllowCustomText="false" >                                
                                    <ItemTemplate>
                                        <div onclick="StopPropagation(event)" >
                                            <asp:CheckBox runat="server" ID="CheckBox1" onclick="checkboxClick(event);" />
                                            <asp:Label runat="server" ID="Label1" AssociatedControlID="CheckBox1" Text='<%# DataBinder.Eval(Container, "DataItem.Location") %>' Font-Size="10pt" Width="88%"  />
                                        </div>
                                    </ItemTemplate>
                                    <CollapseAnimation Duration="200" Type="OutQuint" />
                                </telerik:RadComboBox>

    Me.rcbLocation.DataTextField = "Location"
        Me.rcbLocation.DataValueField = "Location"
        Me.rcbLocation.DataBind()
       Me.rcbLocation.Text=" "
I want to set the input field of Telerik RadComboBox to empty from server side..How can I do it ? Please let me know ..




1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Nov 2009, 07:41 AM
Hi John,

Here is the approach that I tried in order to achieve the desired scenario. I set the AllowCustomText property to True and also set the textbox as ReadOnly from client side, in order to prevent the user to type the text in input field. Give a try with this and see what happens.

ASPX:
 
<telerik:RadComboBox ID="RadComboBox1" runat="server" HighlightTemplatedItems="true" DataSourceID="SqlDataSource1" AllowCustomText="true"  
            OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">           
</telerik:RadComboBox> 

C#:
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        RadComboBox1.Text = ""
    } 

JavaScript:
 
<script type="text/javascript"
    function pageLoad() { 
        var cb = $find("<%= RadComboBox1.ClientID %>"); 
        cb.get_inputDomElement().readOnly = true
    } 
</script> 

-Shinu.
Tags
ComboBox
Asked by
John
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or