Hi,
I need to create a gridview in which i can add data and later save all those rows data to table. How to do that please help
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mayur GujrathiRank #666 · 3.6K reputationPosted Nov 2, 2011, 11:01 PM EDT
Nethra R SRank #6,347 · 269 reputationPosted Nov 2, 2011, 11:21 PM EDT
Thats a good one.. But how to save the rows data entered into sql table?
nagham ghandour9 reputationPosted Nov 2, 2011, 11:50 PM EDT
1st I used the footer of the grid for inserting new rows, sowing or hiding the footer as needed
then, I've created a session variable on load Session["MyDataTable"]=null
filling the grid using objectdatasource with the appropriate function
the using Add button to add the row to the datatable, and when Save sending all rows of DataTable to be inserted.
Nethra R SRank #6,347 · 269 reputationPosted Nov 3, 2011, 12:48 AM EDT
We are here to know the long story please explain how to do that,will be grateful please
nagham ghandour9 reputationPosted Nov 3, 2011, 1:16 AM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted Nov 3, 2011, 3:52 AM EDT
TextBox text1 = new TextBox(); TextBox text2 = new TextBox();
where you are writting your save logic
then
foreach (GridViewRow grow in grid1.Rows)
{
text1= grow .FindControl("TextBox1");
text2= grow .FindControl("TextBox2");
---
----
text7= grow .FindControl("TextBox7");
then save values text1.Text,text2.Text in databse one by one
}
Mark as accepted if this solves your problem