Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi..
I ve 4 entries in a gridview and i ve 4 similar entries in a table. I want to update my table with the entries present in the gridview with the table records. means gridview 1st row shold be updated with the 1st entry in the table and so on.. but it all has to be done automatically..kindly help me..
Posted
Updated 31-May-12 7:32am
v2
Comments
Clifford Nelson 31-May-12 13:40pm    
What environment: ASP.NET, WinForm, WPF...
allagi.arun 1-Jun-12 1:18am    
ASP.NET
db7uk 31-May-12 14:54pm    
added to that, plain old ADO.Net or EF??????
Sandeep Mewara 31-May-12 15:12pm    
And what have you tried? Where are you stuck?
allagi.arun 1-Jun-12 1:19am    
I am not getting to update the table.

If you implement a view model then it is very easy to do. You using bindings to the viewmodel in gridview and table to the same data binding to the fields you want to display. This handles changing the grid when you change your table or vise versa.
 
Share this answer
 
1st select the 1st row details from gridview den use for loop to insert the into new table with additional information.


for(int i=0;i<gridview1.rows.count;i++)>
{
string staff_name = GridView1.Rows[i].Cells[1].Text;
string staff_dept = GridView1.Rows[i].Cells[2].Text;
string str = "insert into intrmarks(VTUNO,ROLLNO,NAME,DEPARTMENT,SEM,IA1,IA2,IA3,FINAL_MARKS,mobile,email,Staff_Name,SUBJECT_NAME)values('" + txtvtu.Text + "','" + Convert.ToInt32(txtrno.Text) + "','" + txtsname.Text + "','" + ddldes.Text + "','" + Convert.ToInt32(ddlsem.Text) + "',0,0,0,0,'" + txtmob.Text + "','" + txteml.Text + "','"+staff_name+"','"+staff_dept+"')";
SqlCommand strCmd = new SqlCommand(str, con);
strCmd.ExecuteNonQuery();

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900