
I need create a textbox into a gridcolumn, but it's dinamic in with c# code.
Thanks
David.
6 Answers, 1 is accepted
You can add the texbox in the ItemCreated event of the grid. It is fired for all items and the you can find the specific cell in which to add the textbox.
Find more information on accessing grid cells and rows in the below article:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html
Greetings,
Iana
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.

It's confuse for me.
I have the following code:
RadGrid MiRadGrid = new RadGrid();
TemplateColumn MiColumna = new TemplateColumn();
TextBox MiTextBox = new TextBox();
MiTextBox.ID =
"MiTextBox";
MiColumna.ItemTemplate = MiTextBox; //Error
MiRadGrid.Columns.Add(MiColumna);
It shows an error, and I don't know solve.
Thanks.

Try the following snippet code. Hope it helps you.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem Item = (GridDataItem)e.Item;
TableCell cell = Item[
"EmpId"
];
TextBox txtBox =
new
TextBox();
txtBox.ID =
"Txt1"
;
cell.Controls.Add(txtBox);
}
}
Also refer the following help article.
Programmatic creation
Thanks,
Princy

Hello Princy,
I follow your code to create a dynamic textbox from the radgrid_ItemDataBound. In my case, by default I set the display property to false. How do I change the property display to true when user click on a different radgrid_SelectedIndexChanged? Please see my code below:
protected void scheduleRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem note = (GridDataItem)e.Item;
TableCell cell = note["Note"];
RadTextBox txtBox = new RadTextBox();
txtBox.ID = "txtNote";
txtBox.Width = 500; //or Unit.Pixel(500)
txtBox.MaxLength = 1000;
txtBox.TextMode = InputMode.MultiLine;
cell.Controls.Add(txtBox);
txtBox.Display = false;
}
}
and I want to turn the textbox display = true from here:
protected void doctorRadGrid_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridDataItem gridItem in scheduleRadGrid.Items)
{
((RadTextBox)gridItem.FindControl("txtNote")).Display = true;
}
}
but it's not working. Please help! thanks a lot!

You should create the controls in ItemCreated event handler. Also check the following help documentation.
Distinguishing the major differences between ItemCreated and ItemDataBound events
-Shinu.

Han