RadComboBox for ASP.NET AJAX

RadControls for ASP.NET AJAX

HeaderTemplate element of the RadComboBox, allows the header of the items in the drop-down list, to be customized. The header is especially useful if your item template displays attributes in multiple columns, although it can be used with any RadComboBox item style. It could be used even when RadComboBox does not have an ItemTemplate defined. Like the ItemTemplate, the HeaderTemplate can include any HTML element.

The following example shows how to create a multi-column RadComboBox with a header that labels the columns of each item.

Note

Both, the HeaderTemplate and ItemTemplate, lay out items using a table that fixes column width, so that the header and items line up properly.

Defining HeaderTemplates inline

CopyASPX
<telerik:radcombobox 
    id="RadComboBox1" 
    runat="server"
    height="190px" 
    width="420px"
    markfirstmatch="true" 
    datasourceid="MyDataSource" 
    highlighttemplateditems="true"
    onitemdatabound="RadComboBox1_ItemDataBound"> 
<HeaderTemplate>   
    <table style="width: 415px; text-align: left">     
        <tr>        
            <td style="width: 125px;">Company Name</td>        
            <td style="width: 125px;">City</td>        
            <td style="width: 125px;">Title</td>        
            <td style="width: 40px;" align="right">            
                <img alt="" src="img/help.gif" />        
            </td>     
        </tr>   
    </table> 
</HeaderTemplate> 
<ItemTemplate>   
    <table style="width: 415px; text-align: left">     
    <tr>        
        <td style="width: 125px;">            
            <%# DataBinder.Eval(Container.DataItem"CompanyName") %>        
        </td>        
        <td style="width: 125px;">
            <%# DataBinder.Eval(Container.DataItem"City") %>        
        </td>        
        <td style="width: 125px;">
            <%# DataBinder.Eval(Container.DataItem"ContactTitle") %>        
        </td>        
        <td style="width: 40px;"></td>     
    </tr>  
    </table> 
</ItemTemplate>
</telerik:radcombobox>

ItemDataBound

The result looks as follows:

MultiColumn ComboBox

Defining HeaderTemplates at run-time

CopyASPX
<telerik:radcombobox 
    id="RadComboBox1" 
    runat="server" 
    radcomboboximageposition="Right"
    autopostback="true">            
</telerik:radcombobox>

Accessing controls in HeaderTemplate

You can find any control embedded in the RadComboBox' HeaderTemplate, like:

See Also

Other Resources