473,700 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error when deleting record from a gridview

13 New Member
hi all,

I have this error when I click delete link in the gridview:

'unable to cast object of type 'ASP.WebForm1_a spx' to type "system.Web.UI. WebControls.Gri dviewRow'

I really need help as soon as possible :(
Dec 22 '09 #1
4 1746
102 New Member
Explicit conversions (casts) require a cast operator. The source and destination variables are compatible, but there is a risk of data loss because the type of the destination variable is a smaller size than (or is a base class of) the source variable.

So you can try this:

Gridview gv = (Gridview)sende r
//Your code here
Dec 22 '09 #2
Queen Soso
13 New Member
what do u mean by sender?

my line is already casted to (GridviewRow).
Dec 22 '09 #3
102 New Member
I hope this example will make the conception clear:

Expand|Select|Wrap|Line Numbers
  1. class Test
  2. {
  3.     static void Main()
  4.     {
  5.         double x = 1234.7;
  6.         int a;
  7.         // Cast double to int.
  8.         a = (int)x;
  9.         System.Console.WriteLine(a);
  10.     }
  11. }
  12. // Output: 1234
Dec 23 '09 #4
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
'unable to cast object of type 'ASP.WebForm1_a spx' to type "system.Web.UI. WebControls.Gri dviewRow'
Basically you are trying to case form type to GridviewRow type.
Sanji told you to typecast it....

Use like this.

Expand|Select|Wrap|Line Numbers
  1. GridviewRow myGridRow = sender as GridviewRow;
Dheeraj Joshi
Dec 23 '09 #5

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

Similar topics

by: Matthew Louden | last post by:
The following ASP code yields the following error, but actually the new record is stored in database. The same error happens when the application deletes a record, such as sqlStmt ="delete from test where username='2323'" Any ideas? Thanks! <% Dim objRS, sqlStmt Set objRS = Server.CreateObject ("ADODB.Recordset") sqlStmt = "insert into test VALUES ('2341', '2341');"
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings True End If ExitHere: Me!SubName.SetFocus
by: RAllsopp | last post by:
I am having trouble deleting a record from a subform. I actually have a main form with two subforms, one dependent on the record selected in the other. The user selects a record to view on the main form and then can add/edit info on the first subform, which then allows you to enter related info on the second subform. When I try to delete a record from the first subform (and cascade all related records from the second subform), the...
by: iam247 | last post by:
Hi I am a relative beginner with SQL and ASP. With some help after previous posts I have a page which successfully requests querystrings from another page and deletes a record from an access table, However, I get the error message: "Row handle referred to a deleted row or a row marked for deletion" I am using access 2002, the table only has 2 fields (ContactID and
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. Thanks Hans
by: gr8beer | last post by:
The gridview rebinds data before the RowCommand or RowEditing events fire. So, if a new record is added to the underlying datasource that changes the index of the row you are trying to edit, you get the wrong row displayed for editing. I am guessing same is true when deleting which is even worse, especially if you are not confirming on delete. How do I either force the gridview not to rebind the data when edit is selected or force the...
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
by: AG | last post by:
Hi, ASP.NET 2.0 web app I have a GridView utilizing template columns and bound to an objectdatasource. In the edit template of one column there is a dropdownlist bound to another objectdatasource. The dropdownlist displays the appropriate values when entering edit mode. However when I try to update, I receive the following error.
by: =?Utf-8?B?Sm9l?= | last post by:
Very weird; I lost a day worth of work because of this problem. I have an ASP.NET application written in VB that is using MySQL database. Shortly, a page creates a Customer record in the database and if successful, creates a directory on the web server. I was using Transaction Scope to accomplish this action; here is the code excerpt: ' Initialize the return value to zero Dim returnValue As Integer = 0
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.