I have 5 textboxs, 1 button and 1 Gridview control.

I just want that when I click the button, text of each textbox will be added in the Gridview in separate column. Each time I will click the button, a new row must be inserted in the Gridview below the last row.
PLEASE TELL ME HOW TO DO IT

Recommended Answers

All 2 Replies

First you need to create datatable with some column and bind it with gridview.

Now when you click on button, create NewRow by below way.

DataRow dRow = your DataTable.NewRow();

now your can use dRow object to store value of your text box in below way.

dRow[“your column name in datatable”] = your textbox.Text;

then at the end add this data row to your data table.

Your DataTable.Rows.Add(dRow);

now bind your data table to girdview

Gridview.DataSource = your data table;

I have 5 textboxs, 1 button and 1 Gridview control.

I just want that when I click the button, text of each textbox will be added in the Gridview in separate column. Each time I will click the button, a new row must be inserted in the Gridview below the last row.
PLEASE TELL ME HOW TO DO IT

display ur code then will definatly assist u becouse i am not able to understand that u r creating dynamic row or what just show ur code u will get solution

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.