A
Alan Z. Scharf
agrids on six different pages which are editable. They each
draw from a different SQLServer table.
2. When data is changed in any rows, the Row ID gets added to an array, and
then a Stored Procedure updates the database table by looping through the
array of Row ID's.
I'm using the RowChanged event to add to the array via the function below.
3. The grids populate OK when the paages are opened, so there is no problem
with connection..
4. However, when I edit data and press Save to run the update procedure, I
get 'Specified cast is not valid error 'on the line that is casting the
datagruid item.
5. All editable grids worked for months and then all stopped working at the
same time.
Any idea what would cause this problem?
Thanks.
Alan
Function
---------------------------------------
protected void RowChanged(object sender, System.EventArgs e)
{
// Add changed record ID's to ChangedRecordList for SaveRecord loop
--->> Error line: 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);
}
}
Stack trace
----------------------------------------
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
draw from a different SQLServer table.
2. When data is changed in any rows, the Row ID gets added to an array, and
then a Stored Procedure updates the database table by looping through the
array of Row ID's.
I'm using the RowChanged event to add to the array via the function below.
3. The grids populate OK when the paages are opened, so there is no problem
with connection..
4. However, when I edit data and press Save to run the update procedure, I
get 'Specified cast is not valid error 'on the line that is casting the
datagruid item.
5. All editable grids worked for months and then all stopped working at the
same time.
Any idea what would cause this problem?
Thanks.
Alan
Function
---------------------------------------
protected void RowChanged(object sender, System.EventArgs e)
{
// Add changed record ID's to ChangedRecordList for SaveRecord loop
--->> Error line: 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);
}
}
Stack trace
----------------------------------------
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