How to save dynamically created GridView data to Database using jQuery in ASP.Net

nagaraju60
 
on Jul 13, 2017 06:38 AM
Sample_705028.zip
7233 Views

Dear Team,

Create dynamic GridView rows and columns with TextBox in each cell based on row and column value from TextBox using C# in ASP.Net

it's working fine for creating gridview.but how to save the gridview details row by row.
i am not able to get gridview data at the time of saving. could you please explain me how to save the this data. please help me

Thanks in advance

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Results 1 - 5 of 10
dharmendr
 
on Jul 13, 2017 09:30 AM
on Jul 13, 2017 09:48 AM

Hi nagaraju60,

Please let me know how you would define the columns for the table to insert.

If you have created 100 columns then how would you define 100 columns in the insert query for inserting the data to database.

And one more thing is that you can't access the TextBoxes of each row on button click as the controls are generated dynamically it looses after post back. The only way is you have to use javascript or jquery to access the controls with there value.

nagaraju60
 
on Jul 14, 2017 01:24 AM

Hi @dharmendr,

Thanks for giving reply, my requirement is i want to Create dynamic GridView rows and columns with TextBox in each cell based on row and column value from TextBox.
if i create 2x3 means 2- Rows & 3-Columns=6 Fields are textboxes.

(ixj) means i1j1 i1j2 i1j3

                  i2j1 i2j2 i3j3 (These are TextBox Names).

after entering data in textboxes the same data should be store in datatable and this datatable data save in database table.

eg: if i enter text in textboxes like below,


              Apple    bannana         Orange

               grape    watermelon    mango

the above same data should come in to datatable as it is and saving same.

And you also mention

" you can't access the TextBoxes of each row on button click as the controls are generated dynamically it looses after post back. The only way is you have to use javascript or jquery to access the controls with there value."

if the textboxes looses their ids after postback then what is the use of creation of this type of gridviews. i need some suggestion, how to acheive my requirement.
please help me.

Thanks in advance

dharmendr
 
on Jul 14, 2017 06:10 AM

If you have created more than 50 columns then how would you define columns in the insert query for inserting the data to database?

nagaraju60
 
on Jul 14, 2017 11:06 PM
dharmendr says:

If you have created more than 50 columns then how would you define columns in the insert query for inserting the data to database?

 actually i am not required more 10 columns. could you please explain how to do this...

my database table columns are like below,

column Name      Datatype

             Id              int

             [1]           nvarchar(100)

             [2]           nvarchar(100)

             [3]           nvarchar(100)

[4]           nvarchar(100)

[5]           nvarchar(100)

[6]           nvarchar(100)

[7]           nvarchar(100)

[8]           nvarchar(100)

[9]           nvarchar(100)

[10]          nvarchar(100)

 

Results 1 - 5 of 10