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

RadGrid with dynamically created template column containing Multiselect combobox

1 Answer 145 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Abhishek
Top achievements
Rank 1
Abhishek asked on 21 Jun 2011, 10:39 AM
Hi,
I am using a rad grid. I have added custom template columns dynamically. On template column i am having a custom multiselect combobox (RadComboBox with CheckBox and Label inside ItemTemplate).

How can i access the combo selected value on post back due to save buton click.
if possible send me sample solution with dynamically created multiselect ComboBox.

I am using following code snnipet for custom combobox:

public class CustomDDLItemTemplate : ITemplate
{

    ListItemType templateType;
    string ColName = "AppName";

    /// <summary>
    /// Create the template
    /// </summary>
    /// <param name="container"></param>
    public void InstantiateIn(Control container)
    {      
        CheckBox checkBox = new CheckBox();
        Label lblDisplayText = new Label();      

        checkBox.ID = "checkBox";
        checkBox.Attributes.Add("onclick", "onCheckBoxClick(this,'"+ container.ClientID +"');");
        
        lblDisplayText.ID = "label";
        lblDisplayText.DataBinding += new EventHandler(this.Label_DataBind);

        // Create a new HtmlGenericControl.
        HtmlGenericControl NewControl = new HtmlGenericControl("div");

        // Set the properties of the new HtmlGenericControl control.      
        NewControl.Attributes.Add("onclick", "StopPropagation(event);");

        // Add the new HtmlGenericControl to the Controls collection of the PlaceHolder control. 
        container.Controls.Add(NewControl);

        NewControl.Controls.Add(checkBox);
        NewControl.Controls.Add(lblDisplayText);              
        break; 
    }

    public void Label_DataBind(Object sender, EventArgs e)
    {
        Label lbl = (Label)sender;
        RadComboBoxItem radCombo = (RadComboBoxItem)lbl.NamingContainer;     
        lbl.Text = DataBinder.Eval(radCombo.DataItem, ColName).ToString();
    }

  
}


1 Answer, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 24 Jun 2011, 11:39 AM
Hi Abhishek,

Probably you will find helpful the following forum post:

http://www.telerik.com/community/forums/aspnet-ajax/combobox/how-get-the-value-selected-from-a-multi-column-radcombobox.aspx

Regards,
Helen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ComboBox
Asked by
Abhishek
Top achievements
Rank 1
Answers by
Helen
Telerik team
Share this question
or