ASP.NET GridView Editing and RowUpdating

Dear everyone,

I need some help!

There is a GridView in my webApplication which has been generated from a database table, with a stored procedure. Now i want to crate an EDIT function, but I have no idea for it how. I already have a DELETE button, but it was much easier. The tables what I want to edit are different sizes with different column names, this is why is it so hard.

I tried this code in the RowUpdating() to generate a string about the values of my row (It should be enough for me because my SP can handle it):

 for (int i = 0; i < GridView1.Columns.Count - 1; i++) {/*-1 is because the last column is the ID*/ if (i == 0){ TextBox text = (TextBox)row.Cells[i].Controls[0]; values = "'"+text.Text+"'"; // GridView1.Rows[rowNum].Cells[i].Text;row.Cells[i].Controls[0].ToString() TextBox1.Text = text.Text; }else{ TextBox text = (TextBox)row.Cells[i].Controls[0]; values = values + ", '"+text.Text+"'";//GridView1.Rows[rowNum].Cells[i].Text; TextBox1.Text = text.Text; } } TextBox1.Text = values; 

I want to get back something like this:

values = " 'column1Value', 'column2Value', 'column3Value' " 

Is there anyone who can help me to deal with it?

Many thanks!

submitted by /u/kesadae11
[link] [comments]

Leave a Reply