Specified Cast Is Not Valid

Discussion in 'ASP .Net' started by Alan Z. Scharf, Jun 22, 2005.

  1. 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
     
    Alan Z. Scharf, Jun 22, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajit
    Replies:
    1
    Views:
    3,612
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  2. Floela
    Replies:
    3
    Views:
    574
    Jon Skeet
    Jul 10, 2003
  3. Arjen
    Replies:
    1
    Views:
    7,772
    Carl Prothman [MVP]
    Aug 6, 2003
  4. Andrew
    Replies:
    0
    Views:
    666
    Andrew
    Aug 12, 2003
  5. Alan Silver
    Replies:
    5
    Views:
    2,590
    Kevin Spencer
    Feb 15, 2005
Loading...

Share This Page