Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Specified Cast Is Not Valid

Thread Tools

Specified Cast Is Not Valid

Alan Z. Scharf
Posts: n/a
VS.NET 2003
SQLServer 2000
IIS 66.0
1. I have sever web pages with datagrids that draw info from different
respecitve SQLServer tables.

2. The datagrids have Item Templates columns for editing data.

3. The pages initially load their data into the datagrids fine, but when I
edit data, I get the 'Specified Cast IS Not Valid' error below.

4. NOTE: All these pages worked fine for Many Months for data editing, and
then this error started at the same time on all the pages with datagrids.

Other pages with just text boxes used for editing still work fine..

5. Was there anything in any automatic Windows or Net Framework update that
might have changed something?

Thanks very much for any help.

I can't figure this one out. I hadn't changed anything.


Server Error in '/' Application.

Code Section
protected void RowChanged(object sender, System.EventArgs e)
// Add changed record ID's to ChangedRecordList for SaveRecord loop
DataGridItem dgi = (DataGridItem) (((Control) sender).NamingContainer);
int recordID = int.Parse(dgi.Cells[0].Text);

// Add to list if not already there

Error Message:
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 167: {
Line 168: // Add changed record ID's to ChangedRecordList for SaveRecord
Line 169: DataGridItem dgi = (DataGridItem) (((Control)
Line 170: int recordID = int.Parse(dgi.Cells[0].Text);
Line 171:

Source File: d:\inetpub\wwwroot\winfundssql\default.aspx.cs Line: 169

Stack Trace:

[InvalidCastException: Specified cast is not valid.]
NetFunds.Values.RowChanged(Object sender, EventArgs e) in
System.Web.UI.WebControls.TextBox.OnTextChanged(Ev entArgs e) +108

System.Web.UI.WebControls.TextBox.System.Web.UI.IP ostBackDataHandler.RaisePo
stDataChangedEvent() +26
System.Web.UI.Page.RaiseChangedEvents() +115
System.Web.UI.Page.ProcessRequestMain() +1081

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: specified cast is not valid. Why not? Alan Silver ASP .Net 5 02-15-2005 08:08 PM
User Control - InvalidCastException: Specified cast is not valid Ajit ASP .Net 1 04-24-2004 09:28 PM
I get the following error ( Specified cast is not valid ) with Server.Transfer Andrew ASP .Net 0 08-12-2003 08:26 PM
System.InvalidCastException: Specified cast is not valid. Arjen ASP .Net 1 08-06-2003 03:26 AM
System.InvalidCastException: Specified cast is not valid Floela ASP .Net 3 07-10-2003 10:36 AM