473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Delete Row From Gridview On Click Of Delete Link In A Column

HI all
I am using gridview. i have added a column "delete" in gridview through wizard. i want to delete record on the click of respective delete link.
------------inline code---------
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
  2.         <Columns>
  3.             <asp:CommandField ShowDeleteButton="True" />
  4.         </Columns>
  5.     </asp:GridView>
-----------------------------------------------
i need coding for code behind .
thanks
regards
sudha
Oct 31 '07 #1
3 21676
nateraaaa
663 Expert 512MB
Have you searched Google yet? I know there are many useful examples that include the html and the code behind.

Nathan
Oct 31 '07 #2
I recommend you to set DataKeyNames property (Example: Give primary key column name) in that way you will retrieve primary key to perform deletion, after that you will need to add a RowDeleting event. In that event handler you have to add a code similar to this:
Expand|Select|Wrap|Line Numbers
  1. protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  2. {
  3. //First Retrieve Primary Key
  4. Int id = GridView1.DataKeyNames(e.RowIndex);
  5. //Here You will perform deletion simply hit a delete query to the database using the  //id that you have retrieved
  6. DeleteRow();
  7. //Rebind data to updated data
  8. GridView1.DataSource=GetUpdatedData();
  9. GridView1.DataBind();
  10. }
Oct 31 '07 #3
Frinavale
9,735 Expert Mod 8TB
Please review the Tutorial on how to use the GridView control found on MSDN here.

Thanks

-Frinny
Oct 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: KS | last post by:
Im trying to prevent the user from clicking any other links on my page when the user have selected/clicked a href once. Sometimes it takes a while before the next page loads so some user will try...
1
by: Eric Shi | last post by:
Hi, I use ASP.Net build a web application which requires users to login. The link is sent out to the user via email. The users then click the link in the email and the login page is...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
0
by: azbehzad | last post by:
Dear Guys, I have a problem with putting delete confirm in my code I add this code in Gridview_RowDataBound() event protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)...
1
by: =?Utf-8?B?UmFodnlu?= | last post by:
Hi All; I'm working in VS2005, and have a DataGridView that is bound to a datasource. Is there a way to change a column to be a link style column after the DataGridView populates? Here's how I...
1
by: Erik | last post by:
Is there any way I can get index (position) of a column in an ASP .NET 2.0 GridView by referencing the column's name, either by using the DataField or HeaderText properties? A small code snippet...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
3
by: myth0s | last post by:
Hello! In VB.NET I have a GridView that shows a list of dates and beside each date there's a delete button. For a reason I don't know, the delete event seems to be fired twice, but I have...
0
by: t0rmed | last post by:
I am currently creating my project for visual basic, which is particularly a database. However, error code 3021 shows up when I click delete even though I do not have a database. How could I solve...
8
by: ncsthbell | last post by:
I have created a form in access 2007 and have the property set to 'datasheet view'. The record source is a query that displays duplicate rows. I want my user to be able to highlight a row and use...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.