.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

GridView RowDeleting is called twice?

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :ASP.Net

I have a GridView and provide the user with sorting, paging, editing, deleting and selecting functionality.

When the user klicks the delete-button in the GridView, the Row-Deleting event is triggered, the record is correctly deleted from Database after user confirmation. Then the Row-Deleted event is triggered and afterwards the Row-Deleting event is triggered AGAIN, resulting in a second user confirmation and a Delete-instruction running into void if the user confirm again the question.

Between the Row-Deleted event and the second Row-Deleting event I saw the GridView binds his data again (comprehensible because it wants to provide an updated view to the data), maybe somwhow there is generated or provoced the second Row-Deleting event.

My GridView:


<%--<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                     ConnectionString="Data Source=DGUI415372\SQLEXPRESS;Initial Catalog=Rechnung;Integrated Security=True"
                     DeleteCommand="Delete FROM dbo.Rechnung WHERE RechnungsNr = @RechnungsNr"
                     SelectCommand="SELECT Rech.RechnungsNr, Rech.KNR, Rech.NA, Rech.NB, Rech.NT_ID, Anr.NT

View Complete Post

More Related Resource Links

GridView RowDeleting event fires twice !


I'm facing some annoying GridView behavior where it fires the RowDeleting event twice.

I'm doing the very normal (logical) steps for deleting a row from a GridView. Here is what I'm doing:

1- my test Page_Load  method

protected void Page_Load(object sender, EventArgs e)

	GridView1.DataSource = GetDataTable();
	// Note: GetDataTable() returns a non-null DataTable object.
	// Also the DataTable has more than 1 row
	// (i.e. everything is fine with the datatable)

2- the GridView has a Delete Command Field.

3- on tracing I've noticed my RowDeleting event gets fired twice! (also I used a static counter to see how many times the event gets fired when clicking on the GridView delete button, which was also confirmed it that it's counting 2 per each click).

Am I doing something wrong? please help


Error when trying to export gridview to Excel - RegisterForEventValidation can only be called during

I have a pretty basic vb.net page that has textbox control on it and a "generate" button that when clicked, fills a datagrid.  That all works great, but when the user clicks the "Export to Excel" button, I get this error.. RegisterForEventValidation can only be called during Render(); 

Here's my code behind, I thought I included everything I needed...

Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub

Private Sub ExportToExcel(ByVal strFileName As String, ByVal dg As GridView)
        Response.Buffer = True
        Response.ContentType = "application/vnd.ms-excel"
        Response.AddHeader("content-disposition", "attachment;filename=" & strFileName)
        Response.Charset = ""
        Me.EnableViewState = False
        Dim StringWriter As New System.IO.StringWriter()
        Dim HtmlTextWriter As New System.Web.UI.HtmlTextWriter(Str

OnCheckChanged is called when GridView column is not Visible


The example .aspx page below includes a grid containing two checkboxes. The first is hidden because its ItemTemplate.Visible is set to false. What is the cleanest way to avoid OnCheckChanged when the parent cell is not Visible?


  1. Paste sample below into new .aspx and run.
  2. Uncheck 'Visible'
  3. Click 'Test'


Expected Results (since only the 'Visible' checkbox was changed):




Actual Results (OnCheckChanged is called for both checkboxes):







<%@ Page Language="C#" AutoEventWireup="false" Theme="" %>
<script runat="server">
    protected override void OnLoad(EventArgs e)
        Output.Text = String.Empty;
        if (!this.IsPostBack)
            Grid.DataSource = new string[] { nu

how to capture value of javascript function called by GridView Linkbutton Click



i have gridview with linkbutton.when i click linkbutton it should call javascript function which returns value would be input for database functions.

how do i capture javascript function retun value(i am using Registerclientscriptblock)? and that should be input for database function.

Inshort i need to call two function from link button click - one javascript function,one ado.net function which will update value in database.

output of javascript function will be input for database function.

function Getlogitudelantitude(address)


return "35.3434343,-74.334343"


Linkbutton_click(object sender,Eventargs e)


register javascript function .. which should return value

string s = "35.34343,-74.334343"

then call database function(s) - does database operation


please reply..



GridView is firing RowDeleting but I don't want it to


I have a Gridview where I'm doing my delete with the OnRowCommand. After I have the database perform the delete I get an error saying the gridview fired the rowdeleting event and it wasn't handled. Do you know why that would happen? This is my gridview;

<asp:GridView ID="favoritesList" 
                                  Style="z-index: 100; left: 0px; position: relative; width: 100%; " 
                                  CellPadding="4" GridLines="Horizontal" 
                                  ForeColor="#333333" onclick="showBusyBox();" 
                                  AutoGenerateColumns="False" OnRowCommand="favoritesList_RowCommand">
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <EditRowStyle BackCo

Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

AJAX GridView Paging and Sorting using C# in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

GridView Paging Using Ajax in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

Displaying Row Details Tooltip on GridView using JQuery

Continuing exploring JQuery! I decided to implement a feature to display some kind of details related to a row displayed on GridView. For example when displaying employees details on GridView some information might not fit in the GridView because it will make it huge and wide. These infomration can be diplayed as Tooltip. Or when you want to display a picture and some kind of formated text to be diplayed as tooltip when mouse hover on the image.

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

Sortable GridView using jQuery's TableSorter

This article explains how to use jQuery's plug-in Tablesorter to implement client-side sorting in an ASP.NET GridView. This comes in handy especially when an ObjectDataSource is used with a GridView as GridView does not provide sorting out of the box.

Sorting Gridview using Jquery with ASP.NET

I want to show how to sorting a gridview using a Jquery in ASP.NET, it is a flexible client-side table sorting. We have known that Jquery is a new kind of Javascript Library. You can find detail of Jquery in this site http://jquery.com/ there are lot of example with documentation and also allow free download a latest version.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend