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

Setting Header text in Codebehind for a MultiColumn ComboBox.

1 Answer 60 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Guido S
Top achievements
Rank 1
Guido S asked on 26 Nov 2012, 10:23 AM
Hello There,

I kinda have a problem because i would like to set the header data (titles) using the code behind.
cbxName.Header.FindControl("id") doesn't really do the trick.

Why do I need this? Well I need to set the titles in the proper languages.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Guido S
Top achievements
Rank 1
answered on 27 Nov 2012, 03:31 PM
YES I HAVE FOUND A SOLITION!
I think it is kinda crappy and dirty since you have to create a HeaderTemplate class for every RadComboBox you would like to do this.

class ProductSelectorHeaderTemplate : ITemplate
{
    private string _artNr, _name, _brand;
    public void SetHeaderTexts(string artNr, string name , string brand)
    {
        _artNr = artNr;
        _name = name;
        _brand = brand;
    }
 
    public void InstantiateIn(Control container)
    {
        var lt1 = new Literal() {Text =  "<ul><li class='col1'>" + _artNr + "</li>"};
        var lt2 = new Literal() { Text = "<li class='col2'> " + _name + "</li>" };
        var lt3 = new Literal() { Text = "<li class='col3'> " + _brand + "</li></ul>" };
        container.Controls.Add(lt1);
        container.Controls.Add(lt2);
        container.Controls.Add(lt3);
    }
}

I have placed this in the init of the ascx.cs file       

var headerTemplate = new ProductSelectorHeaderTemplate();
headerTemplate.SetHeaderTexts("BLA", "BLABALAA", "i like banana");

Tags
ComboBox
Asked by
Guido S
Top achievements
Rank 1
Answers by
Guido S
Top achievements
Rank 1
Share this question
or