473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Invalid cast in GetEnumerator()

TPS
I am trying to bind a listbox to my custom collection object.

My object implements IEnumerable and crashes when the bind event calls
myobject.GetEnumerator()

I get an Invalid Cast exception in this method:

Here is the class def.:
public class CSLAHeaderCOL : IEnumerable, ICollection
Here is the method that crashes:
public IEnumerator GetEnumerator()
{
return IEnumerator = (IEnumerator)this;
}



Nov 17 '05 #1
2 1277
TPS
I figured it out.

This worked in version 1.0, but looks like the have tightened it up in 2003

I needed to implement IEnumerator as well

public class CSLAHeaderCOL : IEnumerable, ICollection

public class CSLAHeaderCOL : IEnumerable, ICollection, IEnumerator

--
Nov 17 '05 #2
You can dynamically disable form elements via:
document.FORMNAME.ELEMENTNAME.disabled=true;
or

If you want it literally greyed out, you can use CSS to apply a style to the
parts you want changed.

Make a style that sets the areas you want changed to one scheme (white
background, font etc etc) Then when whatever event happens to grey those
areas out, you can change the style attributes and make it a grey background
or some similar effect.
"TPS" <te******@NOBULKmactexas.com> wrote in message
news:eo*************@TK2MSFTNGP10.phx.gbl...
I figured it out.

This worked in version 1.0, but looks like the have tightened it up in 2003
I needed to implement IEnumerator as well

public class CSLAHeaderCOL : IEnumerable, ICollection

public class CSLAHeaderCOL : IEnumerable, ICollection, IEnumerator

--

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John C | last post by:
I'm new to C#, so just point me at the correct reference material if this question has been answered before. When creating a new class which implements the IDictionary interface, two versions of...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
3
by: John Howard | last post by:
Making the following call to a local MSAccess database works fine: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows As Integer Dim strSQL As String Dim ds As New...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
2
by: Sam Marrocco | last post by:
I've constructed a class that inherits the NameObjectCollectionBase class. All works well, but I'd like to shadow the GetEnumerator method so that it returns an actual value *instead of a...
0
by: Dan Holmes | last post by:
I have created a DictionaryClass of type KeyValue (which is also my class). All the properties seem to work correctly but during the for each i have to perform a cast on the DictionaryEntry's...
2
by: =?Utf-8?B?VGVk?= | last post by:
I have been asked to change an existing program which Implemented a Collection Class The current class had what is below (its just a summary of the code) Public Class FieldList Implements...
16
by: colin | last post by:
Hi, is it possible to have a recursive GetEnumerator for traversing a tree structure ? public IEnumerator<DTypeGetEnumerator() { return GetEnumerator(root);
4
by: Tony | last post by:
Hello! Below I have a complete working program.with some simple classes one of these is a generic class. The question is about this method GetCows() {...} which is a member in the generic...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.