Hi, I have got a grid view made up of 15 rows, each of these rows of data contain about 10 columns. Each cell has 1 label and 12 hidden fields. I would need to send the cell's 13 fields(1 label and 12 hidden fields) information to the database. The thing is
the cell's for each row goes into separate tables into the database. For example, cells in row1 has to be inserted into SQL table 1, cells in row2 has to be inserted into SQL table 2 and henceforth. What would be the best approach, I actually created a data
table to store each cells 15 fields information and trying to use stored procedure to insert it into the database. Is this the right approach, appreciate any suggestion on how I can do it.
I actually created a data table to store each cells 15 fields information and trying to use stored procedure to insert it into the database. Is this the right approach,
Yes, you could use stored procedure.
In my opinion, I suggest that you could just use different SQL statement to insert the data to the datebase you want.
string testvalue = (gridview1.FindControl("yourcontrolid") as Label).Text;
string query = "insert into table_name values(" +testvalue+ ")";
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
38 Points
110 Posts
Advice on using Data Table to insert data into SQL.
Apr 06, 2019 12:04 PM|callykalpana|LINK
Contributor
2150 Points
705 Posts
Re: Advice on using Data Table to insert data into SQL.
Apr 08, 2019 09:46 AM|Jenifer Jiang|LINK
Hi callykalpana,
Yes, you could use stored procedure.
In my opinion, I suggest that you could just use different SQL statement to insert the data to the datebase you want.
Reference: https://www.c-sharpcorner.com/blogs/insert-data-into-database-from-gridview-in-asp-net1
Best Regards,
Jenifer
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.