Ask a Question related to ASP.NET General, Design and Development.
-
Arjen #1
System.InvalidCastException: Specified cast is not valid.
Hello,
Does somebody haves a solution for this?
Thanks!
Line 74: if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem) {
Line 75:
Line 76: DataRowView drv = (DataRowView) e.Item.DataItem;
Line 77:
Source File: links.ascx.cs Line: 76
[InvalidCastException: Specified cast is not valid.]
PortalICT.Links.myDataList_ItemDataBound(Object sender,
DataListItemEventArgs e) in links.ascx.cs:76
System.Web.UI.WebControls.DataList.OnItemDataBound (DataListItemEventArgs
e) +110
System.Web.UI.WebControls.DataList.CreateItem(Int3 2 itemIndex,
ListItemType itemType, Boolean dataBind, Object dataItem) +139
System.Web.UI.WebControls.DataList.CreateControlHi erarchy(Boolean
useDataSource) +686
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23
PortalICT.Links.Page_Load(Object sender, EventArgs e) in links.ascx.cs:39
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Control.LoadRecursive() +92
System.Web.UI.Control.LoadRecursive() +92
System.Web.UI.Control.LoadRecursive() +92
System.Web.UI.Page.ProcessRequestMain() +713
Arjen Guest
-
System.InvalidCastException was unhandled
For whatever reason, I am getting an invalidcast exception on this piece of code: gApp = CreateObject("AcroExch.App") This is just part of the... -
System.InvalidCastException in .Net client consuming Axis 1.1 java web service
Hi, I am developing a .Net client for Axis 1.1 web service written in java. The wsdl is generated using, java2WSDL with these switches:: -y WRAPPED... -
dataGrid_ItemDataBound - System.InvalidCastException
Essentially I am trying to convert a particular column in my datagrid to an hyperlink on the fly - I have pasted the relevant code and error below,... -
System.InvalidCastException: Specified cast is not valid. error when updating datagrid
Hello, I am trying to update a record using a data grid. I Have a footer column in my data grid that allows users to add a new record. However, I... -
System.InvalidCastException: Specified cast is not valid
I keep geting the exception: System.InvalidCastException: Specified cast is not valid. I get this when I try to pass a DataRow into an object... -
Carl Prothman [MVP] #2
Re: System.InvalidCastException: Specified cast is not valid.
"Arjen" <boah123@hotmail.com> wrote
Arjen,> Does somebody haves a solution for this?
> Line 74: if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> ListItemType.AlternatingItem) {
> Line 75:
> Line 76: DataRowView drv = (DataRowView) e.Item.DataItem;
> Line 77:
> [InvalidCastException: Specified cast is not valid.]
If you use a DataSet to fill the DataList, then that is the correct syntax.
However, if you use a SqlDataReader, then you must use cast the
DataItem to a System.Data.Common.DbDataRecord.
e.g.
System.Data.Common.DbDataRecord dbDataRecord =
(System.Data.Common.DbDataRecord) e.Item.DataItem;
String s = dbDataRecord.GetString(0);
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP
[url]http://www.able-consulting.com[/url]
Carl Prothman [MVP] Guest



Reply With Quote

