1
Answer

How to add data from textboxes to the Gridview in C#

Yasir Imran

Yasir Imran

15y
7.9k
1

Hi All,

 

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 some simplest way to do so. I have tried it by binding Gridview to List<> datasource but the problem is that when ever I clicked the button, new instance of List<> is created  ( e.g List<T> mylist = new List<T>(); ) and the any existing data in the List<> is lost. I used my own entity in the List<>.

 

Please help me with this or any other simple idea  in C#.

Answers (1)