Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Adding a dynamic textbox control to a datagrid with Datatable datasource

Reply
Thread Tools

Adding a dynamic textbox control to a datagrid with Datatable datasource

 
 
JC
Guest
Posts: n/a
 
      09-30-2004
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;
dgQty.DataBind();
 
Reply With Quote
 
 
 
 
Alex Homer
Guest
Posts: n/a
 
      09-30-2004
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/...namicgrid.aspx


 
Reply With Quote
 
 
 
 
James Crane
Guest
Posts: n/a
 
      09-30-2004

Hi Alex,

That's a great start for me - much appreciated

James



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource matthew schouppe ASP .Net Datagrid Control 3 04-30-2004 03:02 PM
DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource matthew schouppe ASP .Net 3 04-30-2004 03:02 PM
static DataTable as DataSource for DataGrid preetith@hotmail.com ASP .Net Web Controls 0 11-13-2003 05:00 AM
Adding DataTable Rows To another DataTable J. Babe ASP .Net 1 08-15-2003 05:04 PM
Re: VERY STRANGE BUG? Adding a textbox control causes other textbox control to fail??? S. Justin Gengo ASP .Net 0 07-16-2003 06:51 PM



Advertisments