5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 08 Nov 2013, 04:04 AM
Hi Vitaly,
Please have a look into the code snippet to show a RadComboBox inside another RadComboBox.
ASPX:
Hope this will helps you.
Thanks,
Princy.
Please have a look into the code snippet to show a RadComboBox inside another RadComboBox.
ASPX:
<
telerik:RadComboBox
ID
=
"RadComboBoxMain"
runat
=
"server"
Height
=
"100px"
Width
=
"200px"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"ITEM 1"
Value
=
"SELECT ITEM"
></
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
Text
=
"ITEM 2"
Value
=
"SELECT ITEM"
></
telerik:RadComboBoxItem
>
</
Items
>
<
ItemTemplate
>
<
telerik:RadComboBox
Style
=
"z-index: 7000;"
ID
=
"RadComboBoxInner"
runat
=
"server"
>
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"ITEM1"
Value
=
"SELECT ITEM"
></
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"RadComboBoxItem2"
Value
=
"RadComboBoxItem2"
/>
</
Items
>
</
telerik:RadComboBox
>
</
ItemTemplate
>
</
telerik:RadComboBox
>
Hope this will helps you.
Thanks,
Princy.
0
Vitaly
Top achievements
Rank 1
Iron
Iron
answered on 08 Nov 2013, 02:56 PM
Thanks for your quick respond.I should tell you in more details what I need:
I need main RadCombobox with 3 items:
item 1:Text="TR"
item 2:Text="Processed"
item 3:Text="All"
And I need inner RadCombobox which will only come from first item in main RadCombobox:
Text="Approved"
Text="Entered"
Text="Trans"
In main RadCombobox item2 and item3 stays alone.
Thanks so much for your help.
I need main RadCombobox with 3 items:
item 1:Text="TR"
item 2:Text="Processed"
item 3:Text="All"
And I need inner RadCombobox which will only come from first item in main RadCombobox:
Text="Approved"
Text="Entered"
Text="Trans"
In main RadCombobox item2 and item3 stays alone.
Thanks so much for your help.
0
Princy
Top achievements
Rank 2
answered on 11 Nov 2013, 11:52 AM
Hi Vitaly,
I guess you want to show the inner RadComboBox for only the First Item of the Main RadComboBox. Please have a look into the sample code I tried.
ASPX:
C#:
Thanks,
Princy.
I guess you want to show the inner RadComboBox for only the First Item of the Main RadComboBox. Please have a look into the sample code I tried.
ASPX:
<
telerik:RadComboBox
ID
=
"RadComboBoxMain"
runat
=
"server"
Height
=
"100px"
Width
=
"200px"
OnSelectedIndexChanged
=
"RadComboBoxMain_SelectedIndexChanged"
AutoPostBack
=
"true"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"TR"
></
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
Text
=
"Processed"
Selected
=
'true'
></
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
C#:
protected
void
RadComboBoxMain_SelectedIndexChanged(
object
sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
if
(e.Text ==
"TR"
)
{
RadComboBox inner =
new
RadComboBox();
inner.ID =
"innercombo"
;
RadComboBoxItem item1 =
new
RadComboBoxItem();
item1.Text =
"Approved"
;
RadComboBoxItem item2 =
new
RadComboBoxItem();
item2.Text =
"Entered"
;
RadComboBoxItem item3 =
new
RadComboBoxItem();
item3.Text =
"Trans"
;
item3.Selected =
true
;
inner.Items.Add(item1);
inner.Items.Add(item2);
inner.Items.Add(item3);
inner.Style.Add(
"z-index"
,
"7000"
);
RadComboBoxMain.Items[0].Controls.Add(inner);
}
}
Thanks,
Princy.
0
Vitaly
Top achievements
Rank 1
Iron
Iron
answered on 12 Nov 2013, 03:58 PM
Thanks again for your respond.
It is working but I do have question.
If I choose from inner combobox "Approved" how can I grab this value or text into C# programmatically?
Thanks for your help.
It is working but I do have question.
If I choose from inner combobox "Approved" how can I grab this value or text into C# programmatically?
Thanks for your help.
0
Princy
Top achievements
Rank 2
answered on 13 Nov 2013, 12:04 PM
Hi Vitaly,
You can try the following C# code.
C#:
Since controls added from code behind are lost on postback you can add the inner combobox in the Page_Load() as follows.
C#:
Thanks,
Princy.
You can try the following C# code.
C#:
RadComboBox combo1 = (RadComboBox)RadComboBoxMain.Items[0].FindControl(
"innercombo"
);
string
text = combo1.SelectedItem.Text;
Since controls added from code behind are lost on postback you can add the inner combobox in the Page_Load() as follows.
C#:
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(RadComboBoxMain.SelectedItem.Text ==
"TR"
)
{
RadComboBox inner =
new
RadComboBox();
inner.ID =
"innercombo"
;
RadComboBoxItem item1 =
new
RadComboBoxItem();
item1.Text =
"Approved"
;
RadComboBoxItem item2 =
new
RadComboBoxItem();
item2.Text =
"Entered"
;
RadComboBoxItem item3 =
new
RadComboBoxItem();
item3.Text =
"Trans"
;
item3.Selected =
true
;
inner.Items.Add(item1);
inner.Items.Add(item2);
inner.Items.Add(item3);
inner.Style.Add(
"z-index"
,
"7000"
);
RadComboBoxMain.Items[0].Controls.Add(inner);
}
}
Thanks,
Princy.