hi all,
I'm using Asp.net Ajax Radgrid for my application but i have one problem that how to generate combobox column dynamically in radgrid.
Can anyone suggest me how to add combobox column in radgrid dynamically so that i can populate combobox at itemcreated or itemdatabound event of radgrid.
Thanks in advance!!!
I'm using Asp.net Ajax Radgrid for my application but i have one problem that how to generate combobox column dynamically in radgrid.
Can anyone suggest me how to add combobox column in radgrid dynamically so that i can populate combobox at itemcreated or itemdatabound event of radgrid.
Thanks in advance!!!
4 Answers, 1 is accepted
0
Hello Sandeep,
Please test the following snippet:
Programmatic Creation On PageLoad demo
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please test the following snippet:
protected void Page_Load(object sender, EventArgs e) |
{ |
GridCheckBoxColumn checkBoxColumn = new GridCheckBoxColumn(); |
RadGrid1.MasterTableView.Columns.Add(checkBoxColumn); |
checkBoxColumn.UniqueName = "myCheckBoxColumn"; |
checkBoxColumn.HeaderText = "CheckBox Column"; |
} |
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
CheckBox checkBox1 = (CheckBox)((GridDataItem)e.Item)["myCheckBoxColumn"].Controls[0]; |
checkBox1.Checked = true; |
} |
} |
Programmatic Creation On PageLoad demo
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kris
Top achievements
Rank 1
answered on 10 Dec 2009, 11:00 PM
That is pretty slick.
How would I let the user check or uncheck the boxes at their leisure? I've tried setting the ReadOnly property of the column but it is stilled greyed out and not editable.
Thanks
How would I let the user check or uncheck the boxes at their leisure? I've tried setting the ReadOnly property of the column but it is stilled greyed out and not editable.
Thanks
0
Princy
Top achievements
Rank 2
answered on 11 Dec 2009, 05:23 AM
Hello Kris,
You can either access the checkboxes and enable it in the code behind or use TemplateColumns with checkboxes in the ItemTemplate. Here's the code to enable checkboxes for a checkboxcolumn:
c#:
Thanks
Princy.
You can either access the checkboxes and enable it in the code behind or use TemplateColumns with checkboxes in the ItemTemplate. Here's the code to enable checkboxes for a checkboxcolumn:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
CheckBox checkBox1 = (CheckBox)((GridDataItem)e.Item)["CheckBoxColumnUniqueName"].Controls[0]; |
checkBox1.Enabled = true; |
} |
} |
Thanks
Princy.
0
Kris
Top achievements
Rank 1
answered on 11 Dec 2009, 02:51 PM
Nice, that works exactly how I need it to. Thanks.