System.InvalidCastException Iterating Through Viewdata

Jan 19, 2011

System.InvalidCastException iterating through Viewdata

I need to replace the code
"<%=Html.DropDownList("Part", (SelectList)ViewData["Parts"])%>"
for dropdown in the following manner for some reason.
<% foreach (Hexsolve.Data.BusinessObjects.HSPartList item in (IEnumerable)ViewData["Parts"])
{ %>
">
<%=item.PartName %>
<%=item.IssueNo %>
<% } %>

I am getting error converting SelectedList to IEnumerable) Error: Unable to cast object of type 'System.Web.Mvc.SelectList' to type 'System.Collections.Generic.IEnumerable`1[Hexsolve.Data.BusinessObjects.HSPartList]'. Is this the right way to iterate through viewdata[].

View 1 Replies


Similar Messages:

SQL Server :: System.InvalidCastException: Specified Cast Is Not Valid?

Jul 25, 2010

I've got a list of teams which seperate into different leagues. I'm trying to show the user the league that they are in and show it from where they are in the league. This is the error I'm recieving: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:

[Code]....

Source File: E:WebSitesohuntControlsLeagueWidget.ascx.vb Line: 24 Stack Trace:

[Code]....

This is my page code:

[Code]....

Code-behind:

[Code]....

View 9 Replies

Forms Data Controls :: Getting 'System.InvalidCastException' When Assigning A Label Color Via Field Value?

Jan 25, 2010

I have a very simple FormView that has several fields on it. There is a field that either returns a "1" or "0" based on conditions in the database. If the value is "1", I want to leave the label control as is (normal font, in black). However, if the value is "0" I want to change the font to bold and change the forecolor to red. Simple, right?

I am able to change the font-bold property using the code below, but if I use the code to attempt to change the font color, I get the following error message for this line:

An exception of type 'System.InvalidCastException' occurred in App_Web_hoge3m1x.dll but was not handled in user code

Additional information: Specified cast is not valid.

[Code]....

View 2 Replies

Iterating System.Collection.Generic.List.Add Does Not Work As Expected?

Mar 7, 2010

I was building an application for a project with .NET 3.5 and I noticed a weird behaviour of the List.Add method:

I have built my own class to organize data pulled from a database, and I use a while cycle to iterate through it.

However, when I List.Add(item), the whole content of the list is substituted with the last content pulled.

An example:

Suppose you have 3 users in a DB, each one identified with an ID and a username:

| ID | username |
| 1 | John |
| 2 | Fred |
| 3 | Paul |

and you have a "Users" class defined as

public class Users
{
private Int32 iD;
private String username;
public Int32 ID
{
get { return iD; }
set { iD = value; }
}
public String Username
{
get { return username; }
set { username = value; }
}
}

So you write this function:

[... SQL definitions - sdr is a SqlDataReader ...]
List<Users> userlist = new List<Users>();
if (sdr.HasRows) //There are users
{
Users user = new Users();
while (sdr.Read())
{
user.ID = sdr.GetInt32(0);
user.username = sdr.GetString(1);
userlist.Add(user);
}
}

What you expect (I expect) is userlist containing:

| ID | username |
| 1 | John |
| 2 | Fred |
| 3 | Paul |

What I actually get is, instead

| ID | username |
| 3 | Paul |
| 3 | Paul |
| 3 | Paul |

View 3 Replies

SQL Reporting :: InvalidCastException When Going To Second Page Of Report

Aug 12, 2010

Using SSRS 2000 (SP2) - I have several reports that come up fine when displaying the first page. However, upon hitting the arrow in the ReportViewer to move to page 2 (or the last page, doesn't matter) , I get a "Reporting Services Error":

An unexpected error occurred in Report Processing. (rsInternalError)

Specified cast is not valid.I'm going to include below the point in the log at which the error shows up - something to do with GetChunkPointerAndLength... does anyone know what can cause this, and what the workaround or solution might be?

Here's the log info:

w3wp!chunks!3d4!08/12/2010-15:50:53:: e ERROR: GetChunkPointerAndLength: System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
w3wp!library!3d4!08/12/2010-15:50:53:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SnapshotChunkStreamFactory.CreateReadStream(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, String& mimeType)
at Microsoft.ReportingServices.Library.ReportSnapshot.GetReportChunk(String name, ReportChunkTypes type, String& mimeType)
at Microsoft.ReportingServices.Library.SessionReportItem.GetImage(String imageId)
at Microsoft.ReportingServices.Library.RSService.InternalGetReportImageLive(ClientRequest session, CatalogItemContext itemContext, String imageId)
at Microsoft.ReportingServices.Library.RSService.InternalGetReportImage(ClientRequest session, CatalogItemContext itemContext)
at Microsoft.ReportingServices.Library.RSService.GetReportImage(ClientRequest session, CatalogItemContext itemContext)
--- End of inner exception stack trace ---
w3wp!webserver!3d4!08/12/2010-15:50:58:: e ERROR: Reporting Services error Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.InvalidCastException: Specified cast is not valid.
w3wp!library!3d4!08/12/2010-15:51:06:: i INFO: Call to RenderNext( '/MasterReconciliationByType/WillCallwCC' )
w3wp!chunks!3d4!08/12/2010-15:51:06:: e ERROR: GetChunkPointerAndLength: System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
w3wp!processing!3d4!08/12/2010-15:51:06:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing., ; Info: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SnapshotChunkStreamFactory.CreateReadStream(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, String& mimeType)
at Microsoft.ReportingServices.Library.ReportSnapshot.GetReportChunk(String name, ReportChunkTypes type, String& mimeType)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.a(GetReportChunk A_0, CreateReportChunk A_1, Hashtable& A_2, a& A_3, Boolean& A_4)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderSnapshot(CreateReportChunk createChunkCallback, RenderingContext rc, GetResource getResourceCallback)
--- End of inner exception stack trace ---
w3wp!webserver!3d4!08/12/2010-15:51:11:: e ERROR: Reporting Services error Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.InvalidCastException: Specified cast is not valid.
w3wp!library!c3c!08/12/2010-15:51:51:: i INFO: Call to RenderNext( '/MasterReconciliationByType/WillCallwCC' )
w3wp!chunks!c3c!08/12/2010-15:51:51:: e ERROR: GetChunkPointerAndLength: System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
w3wp!processing!c3c!08/12/2010-15:51:51:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing., ; Info: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SnapshotChunkStreamFactory.CreateReadStream(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, String& mimeType)
at Microsoft.ReportingServices.Library.ReportSnapshot.GetReportChunk(String name, ReportChunkTypes type, String& mimeType)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.a(GetReportChunk A_0, CreateReportChunk A_1, Hashtable& A_2, a& A_3, Boolean& A_4)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderSnapshot(CreateReportChunk createChunkCallback, RenderingContext rc, GetResource getResourceCallback)
--- End of inner exception stack trace ---
w3wp!webserver!c3c!08/12/2010-15:51:56:: e ERROR: Reporting Services error Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.InvalidCastException: Specified cast is not valid.
w3wp!session!c3c!08/12/2010-15:52:06:: i INFO: LoadSnapshot: Item with session: vrfg4l451fvetg55mqr3zp45, reportPath: /MasterReconciliationByType/WillCallwCC, userName: MASTER
sexec not found in the database
w3wp!library!c3c!08/12/2010-15:52:06:: i INFO: Call to RenderFirst( '/MasterReconciliationByType/WillCallwCC' )
w3wp!library!c3c!08/12/2010-15:52:11:: i INFO: Initializing EnableExecutionLogging to 'True' as specified in Server system properties.
w3wp!webserver!c3c!08/12/2010-15:52:11:: i INFO: Processed report. Report='/MasterReconciliationByType/WillCallwCC', Stream=''
w3wp!chunks!c3c!08/12/2010-15:52:11:: e ERROR: GetChunkPointerAndLength: System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
w3wp!library!c3c!08/12/2010-15:52:11:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SnapshotChunkStreamFactory.CreateReadStream(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, String& mimeType)
at Microsoft.ReportingServices.Library.ReportSnapshot.GetReportChunk(String name, ReportChunkTypes type, String& mimeType)
at Microsoft.ReportingServices.Library.SessionReportItem.GetImage(String imageId)
at Microsoft.ReportingServices.Library.RSService.InternalGetReportImageLive(ClientRequest session, CatalogItemContext itemContext, String imageId)
at Microsoft.ReportingServices.Library.RSService.InternalGetReportImage(ClientRequest session, CatalogItemContext itemContext)
at Microsoft.ReportingServices.Library.RSService.GetReportImage(ClientRequest session, CatalogItemContext itemContext)
--- End of inner exception stack trace ---
w3wp!webserver!c3c!08/12/2010-15:52:16:: e ERROR: Reporting Services error Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.InvalidCastException:
Specified cast is not valid.
w3wp!library!1e50!08/12/2010-15:52:23:: i INFO: Call to RenderNext( '/MasterReconciliationByType/WillCallwCC' )
w3wp!chunks!1e50!08/12/2010-15:52:23:: e ERROR: GetChunkPointerAndLength: System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
w3wp!processing!1e50!08/12/2010-15:52:23:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing., ;
Info: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SnapshotChunkStreamFactory.CreateReadStream(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, String& mimeType)
at Microsoft.ReportingServices.Library.ReportSnapshot.GetReportChunk(String name, ReportChunkTypes type, String& mimeType)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.a(GetReportChunk A_0, CreateReportChunk A_1, Hashtable& A_2, a& A_3, Boolean& A_4)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderSnapshot(CreateReportChunk createChunkCallback, RenderingContext rc, GetResource getResourceCallback)
--- End of inner exception stack trace ---
w3wp!webserver!1e50!08/12/2010-15:52:28:: e ERROR: Reporting Services error Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.InvalidCastException: Specified cast is not valid.
w3wp!session!3d4!08/12/2010-15:56:51:: i INFO: LoadSnapshot: Item with session: gavqaq55mhxzux45xiaulrfe, reportPath: /MasterReconciliationByType/WillCallwCC, userName: MASTER
sexec not found in the database
w3wp!library!3d4!08/12/2010-15:56:51:: i INFO: Call to RenderFirst( '/MasterReconciliationByType/WillCallwCC' )
w3wp!library!3d4!08/12/2010-15:56:54:: i INFO: Initializing EnableExecutionLogging to 'True' as specified in Server system properties.
w3wp!webserver!3d4!08/12/2010-15:56:54:: i INFO: Processed report. Report='/MasterReconciliationByType/WillCallwCC', Stream=''
w3wp!chunks!3d4!08/12/2010-15:56:54:: e ERROR: GetChunkPointerAndLength: System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
w3wp!library!3d4!08/12/2010-15:56:54:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SnapshotChunkStreamFactory.CreateReadStream(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, String& mimeType)
at Microsoft.ReportingServices.Library.ReportSnapshot.GetReportChunk(String name, ReportChunkTypes type, String& mimeType)
at Microsoft.ReportingServices.Library.SessionReportItem.GetImage(String imageId)
at Microsoft.ReportingServices.Library.RSService.InternalGetReportImageLive(ClientRequest session, CatalogItemContext itemContext, String imageId)
at Microsoft.ReportingServices.Library.RSService.InternalGetReportImage(ClientRequest session, CatalogItemContext itemContext)
at Microsoft.ReportingServices.Library.RSService.GetReportImage(ClientRequest session, CatalogItemContext itemContext)
--- End of inner exception stack trace ---
w3wp!webserver!3d4!08/12/2010-15:56:59:: e ERROR: Reporting Services error Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.InvalidCastException: Specified cast is not valid.
w3wp!library!3d4!08/12/2010-15:59:39:: i INFO: Call to RenderFirst( '/MasterReconciliationByType/SalesDetailAll' )
w3wp!chunks!3d4!08/12/2010-15:59:41:: e ERROR: GetChunkPointerAndLength: System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
w3wp!reportrendering!3d4!08/12/2010-15:59:41:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.WrapperReportRenderingException: Exception of type Microsoft.ReportingServices.ReportRendering.ReportRenderingException was thrown., ; Info: Microsoft.ReportingServices.ReportProcessing.WrapperReportRenderingException: Exception of type Microsoft.ReportingServices.ReportRendering.ReportRenderingException was thrown. ---> Microsoft.ReportingServices.ReportRendering.ReportRenderingException: Exception of type Microsoft.ReportingServices.ReportRendering.ReportRenderingException was thrown. ---> System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlDataReader.GetSqlByte(Int32 i)
at System.Data.SqlClient.SqlDataReader.GetByte(Int32 i)
at Microsoft.ReportingServices.Library.ChunkStorage.GetChunkPointerAndLength(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, Object& chunkPointer, Int64& chunkLength, String& mimeType, ChunkFlags& chunkFlags)
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream.OpenReadStream()
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SqlChunkReadStream..ctor(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType)
at Microsoft.ReportingServices.Library.SnapshotChunkStreamFactory.CreateReadStream(Guid snapshotDataID, Boolean isPermanentSnapshot, String chunkName, Int32 chunkType, String& mimeType)
at Microsoft.ReportingServices.Library.ReportSnapshot.GetReportChunk(String name, ReportChunkTypes type, String& mimeType)

View 3 Replies

MVC :: InvalidCastException When Posting Address Data To Action?

May 7, 2010

I have a Person class with an Address property. The Address contains a Country property of type Country which in turn has a CountryCode property of type string, as follows:

Person.Address.Country.CountryCode

I have a select element on the page with a name of "Country.CountryCode". With MVC 1 this was bound perfectly to the CountryCode property of Country. In MVC 2 however, I get the following error when the page is posted back:

[Code].....

View 9 Replies

Invalidcastexception - Can't Access Custom Membership User In Code

Feb 2, 2010

I've wrote a custom membership provider and a custom membership user. So far so good, I can create users / login etc, but when I try to access the custom membership user in code like this;

Code:
Public Function GetOpportunities() As IQueryable(Of Opportunity)
'Dim p As CiseroMembershipProvider = System.Web.Security.Membership.Provider
'Dim _User = p.GetUser(System.Web.HttpContext.Current.User.Identity, True), CiseroMembershipUser
Dim _User As Curve.CiseroMembershipUser = Nothing
_User = System.Web.Security.Membership.GetUser() 'Dim _CurveUser As New CiseroMembershipUser
'Return From o In Me.ObjectContext.Opportunities Where o.ClientID = User.ClientID
Return From o In Me.ObjectContext.Opportunities Where o.ClientID = _
_User.ClientID Order By o.ModifiedDate Descending
End Function
I get this error:

Unable to cast object of type 'CustomMembershipUser' to type 'Curve.CustomMembershipUser'. When I put a quickwatch on the object System.Web.Security.Membership.GetUser() it is of type CustomMembershipUser. The quickwatch window generates the text DirectCast(System.Web.Security.Membership.GetUser(), CustomMembershipUser) when I click onto the properties, but reevaluating the expression raises the error.

View 3 Replies

Security :: Membership.GetUser(object ProviderUserKey) Throws InvalidCastException In .NET 2.0?

Jan 10, 2011

I have an application that has been running for about 1.5 years. Suddenly, I got a bug report that the support team are receiving an InvalidCastException in the User ManagerUnable to cast object of type 'System.Guid' to type 'System.String'. The line this appears to be happening on is:

string queryStringID = Session["EditID"].ToString();
Guid providerUserKey =
new
Guid(queryStringID)
MembershipUser user =
Membership.GetUser(providerUserKey);
<--- here

This is a rather strange error as the value of the queryStringID is in fact a Guid generated by the Membership.GetUser(UserName).ProviderUserKey on the previous page. It doesn't seem to make any sense at all. I'm using the built-in SqlMembershipProvider with no changes. It's as if it isn't picking up that it should be using the overloaded function Membership.GetUser(object providerUserKey)Anyone else ever seen anything like this? I wouldn't normally post here unless I was absolutely stuck but I can't seem to find any relevant information by Googleing this one. Also, it's just started doing this. There was never an issue before. Very strange

View 5 Replies

C# - Iterating Through TextBoxes - Not Working?

Nov 3, 2010

I have 2 methods I tried to iterate through all my textboxes in an asp.net page. The first is working, but the second one is not returning anything. Could someone explain to me why the second one is not working?

This works ok:

[code]....

View 3 Replies

C# - Iterating Through A Listview For Specific ID?

Jan 20, 2010

I've got some labels in a listview, 2 per row. One contains a title, the other information. I want to change all the titles when the user presses a button that fires the ListViewSelectEventArgs. I think they have the same ID since they're from the ItemTemplate, so I thought that's how'd I target them. I'm just not sure how I'd step through the listview.

Here's my attempt:

int x = 1;
for( int i = 0 ; i < this.lvSteps.Controls[0].Controls.Count; i++ )
{
if ( this.lvSteps.Controls[0].Controls[i].GetType() == typeof(Label) &&
( this.lvSteps.Controls[0].Controls[i].ID == "lblStepNumber" ||
this.lvSteps.Controls[0].Controls[i].ID == "lblNewStepNumber" ) )
{
Label lbl = this.lvSteps.Controls[0].Controls[i] as Label;
lbl.Text = "Step #" + x;
x++;
}
}

View 1 Replies

MVC :: Iterating Through Form Elements With Same Name?

Mar 21, 2011

Currently, I have a list of PhoneNumber objects that I display. Here's an example of the output of the view:

[Code]....

Notice the naming of these elements: name="existing_phone[labels][6]", name="existing_phone[numbers][6], name="new_phone[labels][]", name="new_phone[numbers][].Back in the Classic ASP days, I recall being able to do something along the lines of:

[Code]....

And that would give me a 2d array of phone numbers to work with. This doesn't seem to work in .NET. Has anyone tried to do something similar that can point me in the right direction?For new phones, I should simply be able to iterate through each item and insert into the database. For existing phones, I should be able to update (or delete if the label or number are blank) records based off of the id number supplied in the array.OR..if anyone has a better, alternate solution, I'm open to something else.

View 5 Replies

Iterating DataView For Update?

Jul 18, 2010

I have a DataView which filters

inputView.RowFilter = "isnull(" + ID1 + ",'')<>'' and isnull(" + reason + ",0)=0";

after this filter i have to update "IsVerified" column of inputView to "1"

Is there something in LINQ to execute the following?

inputView.RowFilter.ForEach(x=>x.Field<IsVerified> =1);

View 1 Replies

Iterating Through Regex Matches?

Mar 2, 2010

I have a string of information that I need to parse. I've written a regular expression to find the information I need. Now how would I iterate through each regex match and add it to a list (or do something to it)?

View 2 Replies

ADO.NET :: Iterating Through Rows In A Table Without Using GridView

Feb 25, 2011

how to iterate through the rows in a database table without using a GridView? I have a DataSet and a SQLDataReader, but I can't iterate through rows using the SqlDataReader.

View 13 Replies

Php - Keep Sql Connection Open For Iterating Many Requests?

Jan 26, 2011

this is general to any operation calling an SQL server, or anything requiring an open connection at that.Say I have anywhere from 20 to 1000 Select calls to make for each item in data being looped. For each step, I'll select from sql, store data locally in a struct, then proceed. This is not a very expensive call, so should I keep the connection open for the entire loop? Or should I open and close every step? How expensive in run time is opening a connection? I would think it'd be better to keep the connection open, but would like to get the correct response for this.

View 4 Replies

C# - How To Remove Rows From Huge Data Table Without Iterating It

Jan 28, 2011

I have a DataTable available with me which contains thousands of rows. There is a column called EmpID which is containing '0' for some of the rows. I want to remove them from my current DataTable and want to create a new correct DataTable. I cannot go row by row checking it since it contains huge amount of data.

View 6 Replies

Forms Data Controls :: Iterating Through Datalist Working Except Last Row?

Jan 22, 2010

I have some code that iterates through three datalists when they are bound and looks for certain values. If those values exist it hides that particular row in the Datalist. This is working beautifully, except the last row in each datalist is unaffected by the iteration. So for example if I have the following numbers 2, 5, 6, 5, 7, 5 and I want to hide all the rows that contain 5, it produces the following: 2, 6, 7, 5.

Here is my code:

Dim dlitem As DataListItem
Dim tb1 As Label
For Each dlitem In OnHoldDataList.Items
tb1 = CType(dlitem.FindControl("LocationLabel"), Label)

[Code]....

View 1 Replies

Forms Data Controls :: Iterating Child Grid Rows On Button Click?

Jun 29, 2010

i am having Nested Gridview and from the child Grid i have to select the checkbox to retrieve the id's by iterating the child grid and that to on the Button Clik which is outside the Gridview.

View 2 Replies

Iterator Not Iterating / Iterator Within The While Loop Returns False For The MoveNext Method?

Mar 16, 2011

I'm having trouble with something that is (or should be) fairly straight-forward.

I have a recursive method that traverses an XML file, writing out the element tag names and values.

This is a snippet from the XML file:

[code]

<root>
<all_companies>
<company_group company_group_ID_attr="1">
<company_group_name>Cleaning</company_group_name>
<company_group_ID>1</company_group_ID>
<company company_ID_attr="2">
<name>Bloomburg</name>
<company_ID>2</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>4</employee_ref>
</employee_refs>
</company>
<company company_ID_attr="4">
<name>Morris</name>
<company_ID>4</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>3</employee_ref>
<employee_ref>1</employee_ref>
</employee_refs>
</company>
<company company_ID_attr="7">
<name>Ajax</name>
<company_ID>7</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>4</employee_ref>
<employee_ref>2</employee_ref>
</employee_refs>
</company>
</company_group>
</all_companies>
</root>

[/code]

I use the following XPath expression to access the first <company group> tag:
"root[1]/all_companies[1]/company_group[1]"

On the first call to the recursive method ("swrite_for_select_certain_stuff"),I see with the debugger that I reach the <company_group_name> tag. A recursive call at that point takes me to the text node within the tag ("Cleaning"), but it is a text type node (not an element), so it returns without writing anything to the output stream.

On return from that second call, things go wrong. The Iterator within the while loop returns false for the MoveNext method, when it should have moved to the <company_group_ID> tag (or so I think it should).

Am I missing something here?

OS is Win XP, and .NET is version 4.0.

My code is as follows:

[Code]....

View 1 Replies

Forms Data Controls :: Iterating Through Controls In Gridview Without Using FindControl

Feb 19, 2010

I have this...

[Code]....

[Code]....

I'm doing this in my Master Page. I want to access a Linkbutton within the Gridview and set the enabled = false; I tested this and it works all the way up to the first if statement.If I insert a response.write to get the frmctrl.ID, I get all of the controls on the page. BUT, can't get the controls within the gridview.How do I get the contorls within the gridview? I prefer not to do this using Findcontorls and esp setting the control to Public.

View 4 Replies

Pass Value Of Id Which Is In ViewData?

Apr 27, 2010

<%#ViewData["id"] %>
<h2>MarkerDetail</h2>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$.ajax({
url:"/Marker/MarkerDetailPartial",
data:"",
success:function(result){
$("#ReplyDetails").html(result);
},
error:function(result){
}
});
});
</script>
<div id="ReplyDetails">
</div>

& i want to send Id only By this Ajax

View 1 Replies

MVC :: PartialView Outside Of Form - ViewData

Mar 16, 2011

I have a little MVC 3 challenge that I am trying to overcome.Here is my scenario:I have a controller called PersonController.cs with 5 methods:Add Add (post) Edit Edit (post) PopulateName(string EmailAddress) - POST

I have a viewdata class called PersonViewData.cs with 3 pieces of data:

Email FirstName LastName

I have 2 PageViews (Edit.aspx and Add.aspx)I have 1 PartialView (Details.ascx) - with 3 textboxes (Name, Email, Phone)I want to reuse this partial view in both the Edit.aspx and Add.aspx Views.

The user should NOT enter the First Name/Last Name - rather, once the user has entered the email address (OnChange of Email textbox), the First Name/ Last Name of person should be populated. This is done using the PopulateName(string EmailAddress) controller method. Meaning, I have an AJAX Form inside the partial view

Then once all 3 fields are populated. The user should be able to submit either the Add or Edit HtmlForm.

Code of Edit.aspx:
[Code]....

Code of Add.aspx:
[Code]....

The main issue is as follows:I have an AJAX Form inside the partial view. Since now we have a PageView Form and nested PartialView AjaxForm - Form within a Form - the Browser has a hard time with this concept. In fact, when a person enters an email address, the frmEdit/frmAdd gets submitted.

View 5 Replies

MVC :: Access To The First Data Of ViewData

May 3, 2010

i need to show project information by value of dropdownlist.by using this code i get a list of data to drop down list.now how can i access the first data in ViewData(or record)

[Code]....

View 5 Replies

Creating Dropdownlist From ViewData

Jul 22, 2010

Does anyone have any idea why the code below doesn't give me any value but instead gives me "System.Web.Mvc.SelectListItem"? If I don't do a foreach but instead substitute the ViewData with this

<%= Html.DropDownList("PersonOnCallCheckBoxList") %>, I get the correct value.
foreach (var person in ViewData["Person"] as IEnumerable)
{
%>
<input type="checkbox" value="<%= person %>" /><%= person %><br />
<%
}

View 2 Replies

C# - Difference Between ViewData And ViewModel

Mar 3, 2011

I'm new to .Net development, and now are following NerdDinner tutorial. Just wondering if any of you would be able to tell me What is the differences between ViewData and ViewModel(all I know is they are used to pass some form of data from controller to view) and perhaps tell me on what situation should I use ViewData instead of ViewModel and vice versa

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved