all groups > asp.net datagrid control > september 2004 >
You're in the

asp.net datagrid control

group:

Adding a dynamic textbox control to a datagrid with Datatable datasource



Adding a dynamic textbox control to a datagrid with Datatable datasource james_crane NO[at]SPAM btinternet.com
9/30/2004 3:32:46 AM
asp.net datagrid control: Hi,

I have a datagrid, and I want to bind this to a datatable, and I would
like to have textbox controls and one button control.

The problem is the textbox controls - they don't render, at run time
it just says 'System.Web.UI.WebControls.TableCell'

Any help would be appreciated.

TextBox txtQty = new TextBox();
txtQty.Text="erm";

TableCell oTc = new TableCell();
oTc.Controls.Add(txtQty);
DataTable oDt = new DataTable();
oDt.Columns.Add("Qty");
oDt.Columns.Add("Price");
oDt.Columns.Add("Details");
oDt.Columns.Add("Action");
DataRow oDr = oDt.NewRow();
oDr["Qty"] = oTc;
oDr["Price"] = "1";
oDr["Details"] = "1";
oDt.Rows.Add(oDr);
dgQty.DataSource = oDt;
Re: Adding a dynamic textbox control to a datagrid with Datatable datasource James Crane
9/30/2004 11:41:22 AM

Hi Alex,

That's a great start for me - much appreciated

James



*** Sent via Developersdex http://www.developersdex.com ***
Re: Adding a dynamic textbox control to a datagrid with Datatable datasource Alex Homer
9/30/2004 7:28:14 PM
You seem to be adding the TableCell control to the DataTable, whicvh
contains the data to be rendered. This is why you see the class name. You
need to dynamically create the columns in the DataGrid control to include
the text box. There are plenty of examples on the Web of generating a
DataGrid dynamically, such as:
http://www.daveandal.net/books/6744/webforms/dynamicgrid.aspx

AddThis Social Bookmark Button