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

am gettin specific cast not alowed error an anybody help

string Empid = e.Item.Cells[1].Text;
string Empname = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
string date = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
string Special=((TextBox)e.Item.Cells[4].Controls[0]).Text;
string Sex=((TextBox)e.Item.Cells[5].Controls[0]).Text;



am getting Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


Line 236: string date = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
Line 237: string Special=((TextBox)e.Item.Cells[4].Controls[0]).Text;
Line 238: string Sex=((TextBox)e.Item.Cells[5].Controls[0]).Text;
Line 239:
Line 240: //DateTime dt= String.Format("{0:d}", date);
Mar 16 '07 #1
2 836
SammyB
807 Expert 512MB
Offhand, I would say that Controls[0] is not a Windows.Forms.TextBox but an MSForms.TextBox, but it is unclear what all of your variables represent. HTH --Sam

string Empid = e.Item.Cells[1].Text;
string Empname = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
string date = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
string Special=((TextBox)e.Item.Cells[4].Controls[0]).Text;
string Sex=((TextBox)e.Item.Cells[5].Controls[0]).Text;



am getting Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


Line 236: string date = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
Line 237: string Special=((TextBox)e.Item.Cells[4].Controls[0]).Text;
Line 238: string Sex=((TextBox)e.Item.Cells[5].Controls[0]).Text;
Line 239:
Line 240: //DateTime dt= String.Format("{0:d}", date);
Mar 16 '07 #2
Put a breakpoint in your code and check in the Immediate Window what type of control in returned. I guess, it is not the TextBox that is returned there
Mar 17 '07 #3

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

Similar topics

4
by: Simon Ford | last post by:
Hi All, I'm having trouble understanding exactly how I can do some specific implicit casting. There are two problems here; does anyone know what I should be doing? //---------- // (1)...
1
by: eSapient | last post by:
I get the following error when I run the XML Schema Definition Tool on a XML schema: Error: Error generating classes for schema 'codeGeoFeatureType'. - Specified cast is not valid. The XSD...
1
by: Ben Harper | last post by:
I define an interface in managed C++: I call it ISgPlugin. I implement that interface in a C# dll: Using reflection, I try to load and instantiate that interface from the C++ module. I get far,...
2
by: Fabian | last post by:
Hi, I work with asp.net 2.0 and I have a intermittent error, only happens a few times a day. In the page I evaluate a Query String and then I get data form a database. The code snipped: ...
10
by: PH | last post by:
Hi guys! I need to get the remote EndPoint from when I receive packets when listening in a local port in my computer. I'm using UDP (connection-less) so I only bind the socket to my...
2
by: amit | last post by:
Hi guys I am trying to use Access Database with VB .net. In the stock database I have Fields Code and DrugName; Data Type of both is Text. In the following code line marked with *** gives the...
0
by: prasanth1802 | last post by:
string Empid = e.Item.Cells.Text; string Empname = ((TextBox)e.Item.Cells.Controls).Text; string date = ((TextBox)e.Item.Cells.Controls).Text; string...
0
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
11
by: Dinsdale | last post by:
I am trying to determine what the current cast of an object is. Essentially, if I use GetType, it always returns the original type of the object created but I want to know what the current cast of...
1
by: RYKLOU | last post by:
I am kinda new to php, but i do know what i am doing kinda, but i came across this error when i am trying to upload a file to my website. Fatal error: Allowed memory size of 8388608 bytes...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...

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.