Adding TextBox in GridView

I am using GridView in Asp.net Visual Studio Express edition.

How to add textbox for every row in gridview.

I am working on shopping cart in Asp.net and i have to add textbox to all rows displayed.

Also tell me how to add checkbox control such that users can check the desired rows.

The checkbox control in gridview displays only the values in database.If we want to add seperately not involving database.

Willfin David.



Answer this question

Adding TextBox in GridView

  • mystical

    Take a look at this MSDN Article, Editing the Underlying Data in a GridView.


  • RoKo

    first add handler to this grid to point to the method if you click the button something like this 

    <asp:DataGrid CellPadding="3" ID="DataGrid1" runat="server"
    OnItemCommand="Recordoperate" 

    second build the method

    private void RecordOperate(Object sndr, DataGridCommandEventArgs e)
     {
     TextBox txtb = (TextBox)e.item.FindControl("Textbox1")

    string str = txtb.Text

    //ToDo : use the variable in anything you want

    }

    note that i did that in asp.net 1.1 in vb so i'm not sure if it will work like that or not but i don't think it will be far from that

    hope this helps



  • Bovril2006

    I have added textbox and checkboxes to each row of the gridview.How to get the values of textboxes when a button is clicked.

    Willfin David


  • Adding TextBox in GridView