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

[Solved] Load RadComboBox from database with HTML Formatting

3 Answers 276 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
y
Top achievements
Rank 1
y asked on 19 Nov 2008, 10:40 PM
How would load a RadComboBox from database with HTML Formatting?

Is there a way to perform validation to make sure that user selected a choice from the drop down?

Would you have sample code?

Thank you very much 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Nov 2008, 09:48 AM
Hi,

You can enable html formatting for the ComboBoxItems as shown in the code below.
cs:
 <telerik:RadComboBox ID="RadComboBox1" AutoPostBack="true" HighlightTemplatedItems="true" AllowCustomText="true" DataSourceID="SqlDataSource2" DataTextField="Category" DataValueField="Category" runat="server" > 
       <ItemTemplate>        
        <b> <%# DataBinder.Eval(Container.DataItem, "Category")%></b>             
       </ItemTemplate>         
</telerik:RadComboBox> 

And if you would like to validate your combobox so that the combobox is not left empty, then you can use a RequiredFieldValidator as shown below:
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="RadComboBox1" runat="server" ErrorMessage="RequiredField"
</asp:RequiredFieldValidator> 
<telerik:RadComboBox ID="RadComboBox1" AutoPostBack="true" HighlightTemplatedItems="true" AllowCustomText="true" DataSourceID="SqlDataSource2" DataTextField="Category" DataValueField="Category" runat="server" > 
       <ItemTemplate>        
        <b> <%# DataBinder.Eval(Container.DataItem, "Category")%></b>                         
       </ItemTemplate>         
</telerik:RadComboBox> 

Thanks
Princy.
0
y
Top achievements
Rank 1
answered on 20 Nov 2008, 03:34 PM
Hi,
Thanks for responding.

I would like to load the RadComboBox from vb.net code.

here is what I have done so far:
I am calling a stored procedure and looping through a SQLDataReader

 

 

Public

Shared Sub DDLTklRadFillAvailableTables(ByVal tlkRadDDLAt As RadComboBox)
While myRdr.Read

 

 

    Dim item1 As New RadComboBoxItem()

 

    strItemText =

"Table " + myRdr("TableNumber").ToString + myRdr("DuplicateTableNumberSuffix").ToString

 

 

    strItemText +=

" " + myRdr("ShortDescription").ToString.Replace("'", "`")

 

 

    strItemText +=

" " + myRdr("SeatingSection").ToString.Replace("'", "`")

 

 

   

strItemText += "(" + myRdr("SeatsAvailable").ToString + " Seat(s) Avail)"

 

 

 

   item1.Text = strItemText

 

 

    item1.Value = myRdr(

"TableID").ToString

 

 

    tlkRadDDLAt.Items.Add(item1)

 

End While
End Sub

this works quite well - I would now like to put html tags into the text.

 

0
Rogério
Top achievements
Rank 2
answered on 30 Sep 2009, 02:59 PM
I'm having the same problem.
I would like to put on bold the letters that the user writes on the combobox when populating the combobox with values from SQL datatable using the OnItemsRequested option.

Anyone ever did this?
Tags
ComboBox
Asked by
y
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
y
Top achievements
Rank 1
Rogério
Top achievements
Rank 2
Share this question
or