How to populate DataTable Column with buttons or TextBoxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brendanmcdonagh
    New Member
    • Nov 2007
    • 153

    How to populate DataTable Column with buttons or TextBoxes

    I am trying to provie a way to add or minus or just type the quantity of the desired product on my datatable so I'm thinking the best way is the add a text box or button in a column for each row. How could this be done? Or does anyone know a better way
    I populate and create like so...

    Code:
    dt.Columns.Add(new DataColumn("ImagePath", Type.GetType("System.String")))
    
    row["ImagePath"] = ResolveUrl(url);
    How could I create a column which holds buttons or text boxes and dynamically populate?

    Would also love to know how to the image showing inthe gridview rather than the path, resolveUL doesn't work.
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    You can't add controls like a button or a textbox to a DataTable. You can however bind your DataTable to a DataGridView and add a DataGridViewBut tonColumn and a DataGridViewTex tBoxColumn to your GridView afterwards.

    Code:
    DataGridView1.DataSource = tblData;
    DataGridViewTextBoxColumn dcText = new DataGridViewTextBoxColumn();
    DataGridViewButtonColumn dcButton = new DataGridViewButtonColumn();
    DataGridView1.Columns.Add(dcText);
    DataGridView1.Columns.Add(dcButton);
    Steven
    Last edited by MrMancunian; Aug 3 '09, 11:35 AM. Reason: Changed code from VB.NET to C#

    Comment

    Working...