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

Controls based on columns

1 Answer 31 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryann
Top achievements
Rank 1
Ryann asked on 26 Dec 2013, 02:35 PM
Hi ,
i have two columns, based on first column values i want second column some rows to be a radcombobox or textbox etc. How to do this?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Dec 2013, 02:41 PM
Hi Ryann,

Please try the following code snippet if this doesn't help, please elaborate on your requirements.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem data = (GridDataItem)e.Item;
        string id = data["Column1"].Text;
        data["type"].Text = string.Empty;
        switch (id)
        {
            case "value1":                   
                RadComboBox combo = new RadComboBox();
                combo.DataSourceID = "SqlDataSource1";
                combo.DataTextField = "ID";
                combo.DataValueField = "ID";
                combo.ID = "Radcombobox1";
                data["type"].Controls.Add(combo);
                break;
 
            case "value2":
                TextBox txtbox = new TextBox();                  
                txtbox.ID = "TextBox1";
                data["type"].Controls.Add(txtbox);
                break;               
        }           
    }
}

Thanks,
Shinu
Tags
Grid
Asked by
Ryann
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or