473,385 Members | 1,396 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,385 software developers and data experts.

Datagrid RowDeleting event is fired twice while browsing with IE

Hi

I have a datagrid and and I wrote some code for the RowDeleting event.

While I was developing I tested with Firefox and everything was fine, but since I have potential users that are still using IE6 I started testing with it and then I received the following exception:
Expand|Select|Wrap|Line Numbers
  1. System.ArgumentNullException was unhandled by user code
  2.   Message="Value cannot be null.\r\nParameter name: entity"
  3.   Source="ReportPortal"
  4.   ParamName="entity"
  5.   StackTrace:
  6.        at ReportPortal.Views.Admins.Roles.DeleteRole(Int32 roleId) in C:\ReportPortal\Views\Admins\Roles.aspx.cs:line 71
  7.        at ReportPortal.Views.Admins.Roles.gvRoles_RowDeleting(Object sender, GridViewDeleteEventArgs e) in C:\ReportPortal\Views\Admins\Roles.aspx.cs:line 323
  8.        at System.Web.UI.WebControls.GridView.OnRowDeleting(GridViewDeleteEventArgs e)
  9.        at System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex)
  10.        at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
  11.        at System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument)
  12.        at System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  13.        at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  14.        at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  15.        at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  16.   InnerException: 
  17.  
When I traced the code I realized that RowDeleting Event is been fired twice. The first one deletes the row and the second one, of course, fails. But in FF it works OK so , I can't figure why when I change the browser the event is fired 2 times. Any idea???

This is my code:
Expand|Select|Wrap|Line Numbers
  1. protected void gvRoles_RowDeleting(object sender, GridViewDeleteEventArgs e)
  2.         {
  3.          DeleteRole(Convert.ToInt32(gvRoles.DataKeys[e.RowIndex].Value));
  4.             }
  5.  
  6.  
  7. private void DeleteRole(int roleId)
  8.         {
  9.             CNNDemoDataContext db = new CNNDemoDataContext();
  10.  
  11.             var matchedRole = (from role in db.STRoles
  12.                                where role.RoleId == roleId
  13.                                select role).SingleOrDefault();
  14.  
  15.             try
  16.             {
  17.                 db.STRoles.DeleteOnSubmit(matchedRole);
  18.                 db.SubmitChanges();
  19.             }
  20.             catch (Exception ex)
  21.             {
  22.                 throw ex;
  23.             }
  24.  
  25.         }
Feb 17 '11 #1
0 1438

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

Similar topics

3
by: Peter Row | last post by:
Hi, I have created a user control consisting of a textbox and a separate vertical scroll bar. The textbox is filled with data. However there could be lots of data so I only fill the textbox...
7
by: | last post by:
Hello to all I'm handling the Validating event for one text box. If something is wrong in user input I show a warning message. The problem is that if I add to method the message is displayed...
5
by: Asa Monsey | last post by:
I am having a problem that the page load event fires twice in reponse to an autopostback. The first time, the IsPostBack property is true, and the second time it it false. This is causing many...
4
by: Larry Morris | last post by:
The following code, pasted into a web form with a link button on it, will cause the page_unload event to fire twice. If I remove the response.redirect, the problem goes away :). I've got a work...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
2
by: Girish | last post by:
Hello all, Im wondering why my OnItemDataBound gets fired twice here. I got this sample code from somewhere online.. and when I put a break point in the method... it hits the method twice for...
2
by: scottiedog | last post by:
I didn't notice this until I put debug lines but when a char is send to textbox via button event, e.g. click button1, this happen KeyDow KeyDow KeyPres KeyU KeyU where button2 will do this
2
by: Anup | last post by:
Hi Group, In my application I am using a datagrid, now I m implementing sorting for that datagrid, I am changing the flag for ascending and descending when SortCommand event of datagrid is...
0
by: Daniel | last post by:
I've created a custom control including some Literal ( constructed with html markup) and an ImageButton firing event ( add a vote ). public event VoteCommandEventHandler VoteCommand; protected...
8
by: Learner | last post by:
Hello, I converted a VS 2003 project to VS 2005. It works perfectly alright in VS 2003 but when I try running in VS 2005 I got strange thing going on. The code (my button click event ) runs...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.