Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I want to delete the selected row in griedview and I want that on selecting the select button in gridview the details of that particular record get displayed. I want to perform all this through coding in C#. Please reply.
Posted
Updated 19-Nov-10 1:39am
v2

Since you are talking about GridView, I will consider it as an ASP.NET question.
You need Delete and Select CommandField columns in your GridView.

Check this All-in-one GridView[^] example from CodeProject.

Hope this helps!
 
Share this answer
 
string str = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
SqlCommand cmd = new SqlCommand("delete from tablename where id=@id", con);
cmd.Parameters.AddWithValue("@id", str);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
 
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