Adding a dynamic textbox control to a datagrid with Datatable datasource

Ask a Question related to ASP.NET, Design and Development.

  1. #1

    Default Adding a dynamic textbox control to a datagrid with Datatable datasource

    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();
    JC Guest

  2. Similar Questions and Discussions

    1. Accessing Textbox Text After Postback in Dynamic Control
      I have an aspx page, which loads a custom usercontrol (UCtrlA). UCtrlA has a drop down list, and depending on what is selected in UCtrlA's drop...
    2. How to get DataSource for a DropDownList in a Dynamic DataGrid?
      Howdy! I am in the midsts of converting some DataGrids which were previously built in HTML into dynamicly added DataGrids which will be called...
    3. How to gat DataSource for a DropDownList in a Dynamic DataGrid?
      Howdy! I am in the midsts of converting some DataGrids which were previously built in HTML into dynamicly added DataGrids which will be called...
    4. DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource
      I have a datagrid with two columns, the first a normal bound column, the second is a template column created from a bound column. For the...
    5. VERY STRANGE BUG? Adding a textbox control causes other textbox control to fail???
      I've had this happen a few times too. I'm still not positive of what exactly causes it but all that's happening is the control that no longer...
  3. #2

    Default Re: Adding a dynamic textbox control to a datagrid with Datatable datasource

    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:
    [url]http://www.daveandal.net/books/6744/webforms/dynamicgrid.aspx[/url]


    Alex Homer Guest

  4. #3

    Default Re: Adding a dynamic textbox control to a datagrid with Datatable datasource


    Hi Alex,

    That's a great start for me - much appreciated

    James



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    James Crane Guest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139