Specified Cast Is Not Valid

A

Alan Z. Scharf

this question in datagrid group for several days with no
repsonse.
I'm hoping for an answer her because of greater activity in this group.
No cross-posting intended. Thanks.
-----------------------------------------------------------

Server
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.

Alan




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
if(!ChangedRecordIDList.Contains(recordID))
{
ChangedRecordIDList.Add(recordID);
}
}

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
loop
Line 169: DataGridItem dgi = (DataGridItem) (((Control)
sender).NamingContainer);
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
d:\inetpub\wwwroot\winfundssql\default.aspx.cs:169
System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e) +108

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top