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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mayur GujrathiPosted Nov 3, 2011, 7:52 AM
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
nagham ghandourPosted Nov 3, 2011, 5:16 AM
Nethra R SPosted Nov 3, 2011, 4:48 AM
We are here to know the long story please explain how to do that,will be grateful please
nagham ghandourPosted Nov 3, 2011, 3:50 AM
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 SPosted Nov 3, 2011, 3:21 AM
Thats a good one.. But how to save the rows data entered into sql table?
Mayur GujrathiPosted Nov 3, 2011, 3:01 AM