473,769 Members | 6,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to solve error Unable to cast object of type 'System.Web.UI. WebControls.Dat aContr

7 New Member
Hai,
Pls anyone help me............. ..............
I am using ASP.NET(C#).
I want to display the data in a gridview and make the gridview to become editable and insert and delete.
But i can't perform edit .
when i click update button
It display a error message like this......

Unable to cast object of type 'System.Web.UI. WebControls.Dat aControlLinkBut ton' to type 'System.Web.UI. WebControls.Tex tBox'.

My code is
protected void grdvwteleno_Row Editing(object sender, GridViewEditEve ntArgs e)
{
grdvwteleno.Edi tIndex = e.NewEditIndex;
BindData();
}
protected void grdvwteleno_Row Updating(object sender, GridViewUpdateE ventArgs e)
{
DataTable dt = (DataTable)Sess ion["dt"];

GridViewRow row = grdvwteleno.Row s[e.RowIndex];
dt.Rows[grdvwteleno.Edi tIndex]["SL"] = ((TextBox)(row. Cells[1].Controls[0])).Text.ToStrin g();
dt.Rows[grdvwteleno.Edi tIndex]["Name"] = ((TextBox)(row. Cells[2].Controls[0])).Text.ToStrin g();
dt.Rows[grdvwteleno.Edi tIndex]["Id"] = ((TextBox)(row. Cells[3].Controls[0])).Text.ToStrin g();
Apr 4 '08 #1
1 11387
Plater
7,872 Recognized Expert Expert
Sometimes I wonder about the language barrier.
That error message is very clear. One of those things you think is a TextBox, is really a DataControlLink Button. Figure out which one (it probably pointed to the offending line number in the error message) and correct your mistake.
Apr 4 '08 #2

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

Similar topics

0
7389
by: Pankaj Jain | last post by:
Hi All, I have a class A which is derived from ServicesComponent to participate in automatic transaction with falg Transaction.Required. Class A is exposed to client through remoting on Http channal hosting into IIS. There is a class B which is also available through remoting hosted on IIS on the same URI. B creates new of A inside a function. It succeed and able to create instance of A inside B first time. But it failes in 2nd attempt when...
3
1637
by: Nader | last post by:
Hello all, Any help would be greatly appreciated. In a Web-based application (server is local) I am trying to send an email from the server side by The error occurs at the following line while trying to send an email from the server: SmtpMail.Send(msgMail);
3
3032
by: .Net Sports | last post by:
IN a datagrid code behind, I'm getting a "Specified cast is not valid" error price = (Decimal)(rowData); which was initialized as: Decimal price;
0
1177
by: Andrew | last post by:
Can someone out there help. I am using Server. Transfer from a user control to a webform and tried to follow many examples exactly as specified but cannot get around the (Specified cast is not valid.) ERROR which happens on the second page Search.aspx on the line with (PrevPageValues = (FirstPage)Context.Handler;). I have also got <%@ Reference Page="_FirstPage.ascx" %> at the top of the second page.
0
2903
by: Wes Shaddix | last post by:
I have a vendor web service that I have created a web application to interact with. The service works fine in VS 2003 but fails in VS 2005. I have implemented a proxy between the web client and web service to capture the soap calls and both the request and response are identical. The problem occurs in VS 2005 when the .net runtime attempts to de-serialize the soap response into the custom type defined in the wsdl. The exact error message...
2
1870
by: Dabbler | last post by:
I'm getting the following error when I try and insert a row using FormView, ObjectDataSource and stored procedure. The form has 40+ columns on it and I'm not sure how to diagnose where the problem is, the data object class, the business class etc? Object of type 'System.Int32' cannot be converted to type 'System.String'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack...
0
3584
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.
2
6827
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how to fix this error. I am able to send messages sometimes both other times randomly following error appear EXCEPTION:
1
7112
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down so if you want to start by reading that, search for +++ Also note that I am unable to reproduce...
0
10211
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, 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...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9993
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,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
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 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...
0
6672
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();...
0
5298
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...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
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.