hi,
How to perform Edit,Delete operation in Grid view using Asp.net 2.0 in visual studio 2005?
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
Amit ChoudharyRank #145 · 15.8K reputationPosted Nov 4, 2009, 3:24 AM EST
Hi, Here is the instructions for you problem....
Implementing a Delete, Insert and Update operations you must have a DataAdapter and define its Delete, Insert and Update commands. You could use this adapter against your datasource and call the adapters' update method...
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM table1", conn);
adapter.InsertCommand = new SqlCommand("INSERT INTO table1 VALUES(@param1, @param2)", conn);
adapter.InsertCommand.Parameters.Add("@param1",...);
Just do the same to the Update and Delete commands. Then, Create a DataSet and Fill it using the adapter and make it as a datasource of your datagrid...
DataSet ds = new DataSet();
adapter.Fill(ds);
DataGrid1.DataSource = ds;
When you want to send your changes to the database you can just call the adapter.update method...
adapter.Update(ds);
========================================
if it helps you mark it as answer..please it'll help me getting some points :)
keshav singhRank #3,113 · 460 reputationPosted Nov 16, 2009, 2:05 AM EST
this will help you
please mark it as Accepted
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 16, 2009, 2:29 AM EST
Here is Simplest Way to Do that Without Writing Single Line of Code :) . if you are Beginner then this will be help full to you .
friend, if my answer helps you then please check "Do you like this answer check box" :)
Bind Your Database table With GridView by Click On SmartTag which is on the Right Top Corner of the GridView
then Select the DataSource From there .
Now In Grid
Step 1 (Click On Samrt Tag As Show Below )
Step 2
While Selecting the DataSource Click On Advance Sql Option button and Check Generate Insert Update Delete Check box
Step 3
Now In SmartTag You Will Have New Options Enable Editing and Delete .Check Them Both
Step 4
you are Done!!
Now your Grid Allow you to Update and delete the DataRows :)
Purushottam RathoreRank #120 · 18.2K reputationPosted Nov 17, 2009, 11:59 PM EST