add text box in grid view

masonic_era

New Member
I want change the content in \[code\]grid view\[/code\] to \[code\]textbox\[/code\].
Here is part of my code \[code\]public class TextBoxTemplate : ITemplate{ public void InstantiateIn(Control container) { TextBox txtBox = new TextBox(); txtBox.ID = "txtBox"; container.Controls.Add(txtBox); }}\[/code\]//dtTeaching is data sourse for grid view \[code\]foreach (DataColumn col in dtTeaching.Columns){ if (col.ColumnName.Contains("Name")) { TemplateField tfName = new TemplateField(); tfName.ItemTemplate = new TextBoxTemplate(); tfName.HeaderText = "Programme Name"; gvTeaching.Columns.Add(tfName); } } gvTeaching.DataSource = dtTeaching; gvTeaching.DataBind(); for (int i = 0; i < gvTeaching.Rows.Count; i++) { TextBox k = (TextBox)gvTeaching.Rows.Cells[0].Controls[0]; k.Text = "test"; }\[/code\]But the result is nothing will display in the grid view.
No \[code\]textbox\[/code\] no content, just 3 blank rows,
 
Back
Top