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

[Solved] RadComboBox Header Not Showing After Update

1 Answer 167 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
nspit
Top achievements
Rank 1
nspit asked on 12 Feb 2010, 11:38 PM
I updated to the latest version of RadControls for ASP.NET AJAX (2008.2 1001 - Oct 1, 2008) and now the header (HeaderTemplate) row will no longer show for all my RadComboBox controls when I do some type of data binding in the HeaderTemplate. If there is no data binding it works. Something broke in this last version and the basic "<%" usage is no longer supported.
 
Not working HeaderTemplate:
                            <HeaderTemplate> 
                                <table cellpadding="0" cellspacing="0" border="0">  
                                    <tr> 
                                        <td style="width:90px; vertical-align:top; text-align:left;"><%= ((SessionState.Language == Natr.Classes.Language.Spanish) ? "No. de Stock" : "Stock Number")%></td>  
                                        <td style="width:320px; vertical-align:top; text-align:left;"><%= ((SessionState.Language == Natr.Classes.Language.Spanish) ? "Descripción" : "Product Name")%></td>  
                                        <td style="width:50px; vertical-align:top; text-align:left;"><%= ((SessionState.Language == Natr.Classes.Language.Spanish) ? "Costo" : "Price")%></td>  
                                    </tr> 
                                </table> 
                            </HeaderTemplate>

 

 

 

 

Working HeaderTemplate:
                            <HeaderTemplate>    
                                <table cellpadding="0" cellspacing="0" border="0">     
                                    <tr>    
                                        <td style="width:90px; vertical-align:top; text-align:left;">Stock Number</td>     
                                        <td style="width:320px; vertical-align:top; text-align:left;">Product Name</td>     
                                        <td style="width:50px; vertical-align:top; text-align:left;">Price</td>     
                                    </tr>    
                                </table>    
                            </HeaderTemplate>    
 

 

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 18 Feb 2010, 01:46 PM
Hi nspit,

Displaying data in RadComboBox header in the manner that you describe is not related with the RadControls version. The approach that you use to display data in HeaderTemplate of RadComboBox is not correct.

I will suggest you to create custom header template class that implements ITemplate interface and then in its InstantiateIn method to define the template that you prefer. This approach is well known and more details you can find here.

public class CustomHeaderTemplate : ITemplate
{
    private string projectTitle;
    private string projectID;
    private string projectPrice;
 
    public string ProjectTitle
    {
        get { return projectTitle; }
        set { projectTitle = value;}
    }
    public string ProjectID
    {
        get { return projectID; }
        set { projectID = value;}
    }
    public string ProjectPrice
    {
        get { return projectPrice; }
        set { projectPrice = value;}
    }
 
    public void InstantiateIn(Control container)
    {
        HtmlTable table = new HtmlTable();
        table.Width = "100%";
        HtmlTableRow row = new HtmlTableRow();
 
        HtmlTableCell cell1 = new HtmlTableCell();
        cell1.InnerHtml = this.ProjectTitle;
        cell1.Width = "50%";
        row.Controls.Add(cell1);
 
        HtmlTableCell cell = new HtmlTableCell();
        cell.InnerHtml = this.ProjectID;
        cell.Width = "30%";
        row.Controls.Add(cell);
   
        HtmlTableCell cell2 = new HtmlTableCell();
        cell2.InnerHtml = this.ProjectPrice;
        cell2.Width = "20%";
 
        row.Controls.Add(cell2);
        table.Controls.Add(row);
        container.Controls.Add(table);
    }
}

The next step is to create the custom header instance in your page class and set the properties:

CustomHeaderTemplate projectHeader;
 
   protected override void OnInit(EventArgs e)
   {
       base.OnInit(e);
       projectHeader = new CustomHeaderTemplate();
       projectHeader.InstantiateIn(new PlaceHolder());
       productsCombo.HeaderTemplate = projectHeader;
   }
 
   protected void Page_Load(object sender, EventArgs e)
   {
       projectHeader.ProjectID =
           (Session["language"] != null  && Session["language"] == "spanish") ? "No. de Stock" : "Stock Number";
       projectHeader.ProjectTitle =
           (Session["language"] != null && Session["language"] == "spanish") ? "Descripción" : "Project Title";
       projectHeader.ProjectPrice =
           (Session["language"] != null && Session["language"] == "spanish") ? "Costo" : "Price";
   }

Note that this approach creates dynamically the header template so there is no need to define it at RadComboBox markup.

Please find more details in sample page attached.
At last I would like to recommend you to download our latest version which is 2009.3.1314.

All the best,
Kalina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
nspit
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or