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

[Solved] ComboBox assigning SelectedIndex

8 Answers 370 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
venm
Top achievements
Rank 1
venm asked on 24 Apr 2008, 01:06 PM
Hi All,

I am currently using Rad Multicolumn Combobox.

The problem is when I set its selected index in my .vb (code behind) file

 Example: RadComboBox1.SelectedIndex = 2

The textbox ( of combobox) will not get populated with the appropriate value & even if I click on the dropdown the appropriate item will not be highlighted.

Any help regarding this will be appreciated. Thanks in advance.

8 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 25 Apr 2008, 12:45 PM
Hello venm,

What about finding the item and selecting it at the client-side using the findItemByText() method of the combobox object and the select() method of the combobox item.

Hope this helps.

Kind regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
venm
Top achievements
Rank 1
answered on 25 Apr 2008, 06:08 PM
Hi Nick
  Thanks for your reply. With the help of your suggession I could able to get selected index property working as expected with normal ComboBox but the same things didnot work for Multicolumn ComboBox.

What I did was 
   After databinding :
                   RadComboBox1.SelectedValue = "" 
     on Button Click event:         
               RadComboBox1.SelectedIndex = RadComboBox1.FindItemIndexByText("Arial")

below is my multicolumn combobox.  Please help me in this regard

<

radC:RadComboBox
ID="RadComboBox1"
runat="server"
skin = "Classic"
Height="100px"
Width="150px"
MarkFirstMatch="true"
EnableLoadOnDemand="true"
HighlightTemplatedItems="true"
DropDownWidth="475px"
ItemRequestTimeout="500"
AllowCustomText ="false" >

<HeaderTemplate >
<table style="width:425px; text-align:left">
<tr>
<td style="width:125px">
Style
</td>
<td style="width:250px">
Sample Text
</td>
</tr>
</table>
</HeaderTemplate>

<ItemTemplate>
<table style="width:425px; text-align:left ">
<tr>
<td style="width:125px">
<%#DataBinder.Eval(Container.DataItem, "FontName")%>
</td>
<td style="width:250px">
<asp:Label ID="lblFont" runat="server"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</radC:RadComboBox>

0
Rosi
Telerik team
answered on 28 Apr 2008, 08:14 AM
Hi Venm,

The reason for the problem is that the Text of Item is not set. I suggest you set DataTextField property of RadComboBox to "FontName"

For an example:
< 
 
radC:RadComboBox   
ID="RadComboBox1"   
runat="server" 
skin = "Classic" 
Height="100px" 
Width="150px" 
MarkFirstMatch="true"   
EnableLoadOnDemand="true"   
HighlightTemplatedItems="true"   
DropDownWidth="475px" 
ItemRequestTimeout="500" 
AllowCustomText ="false" DataTextField="FontName">   
 
 
 
 
In this case RadComboBox1.FindItemIndexByText("Arial") should work.


Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
venm
Top achievements
Rank 1
answered on 29 Apr 2008, 01:14 PM
Hi Rosi,

    Thanks for your reply, I tried your suggestion but no success. Can you please send me any sample running project in this regard.

0
Accepted
Helen
Telerik team
answered on 29 Apr 2008, 04:04 PM
Hi Venm,

Please, find attached a sample project showing how to achieve this. Note that when you use LoadOnDemand(EnableLoadOnDemand="true"), you should set Text instead of SelectedIndex (refer to the LOD.aspx).
In case you are not using LoadOnDemand everything will work as expected (see the NotLOD.aspx).

Hope it will be helpful.

Regards,
Helen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
venm
Top achievements
Rank 1
answered on 30 Apr 2008, 02:45 PM
Hi Helen,
    Thank you so much. It worked as expected.
You made my day. !!!!!!!!!!!

venm
0
Atlas
Top achievements
Rank 1
answered on 28 Jul 2009, 10:02 PM
Does the Selected Value work in this example? And if so, do you have to set it programmatically in the page load rather than in the aspx page in the control declaration?
0
Veselin Vasilev
Telerik team
answered on 29 Jul 2009, 11:57 AM
Hi Nano Sacay,

Both ways should work.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
venm
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
venm
Top achievements
Rank 1
Rosi
Telerik team
Helen
Telerik team
Atlas
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or