473,378 Members | 1,344 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,378 software developers and data experts.

a class inherited from ArrayList, is saved to ViewState, why the type of the object read from ViewSate is not the class, but the parent, ArrayList

a class inherited from ArrayList,
is saved to ViewState,
why the type of the object read from ViewSate is not the class,
but the parent, ArrayList
[my email address le******@hotmail.com]
the class inherited from ArrayList

public class Fields: ArrayList
{
public Fields()
{}
}
Save to ViewState
this.ViewSate["FieldList"] = colFields;

when reading, it raises an error,
Fields colFields = (Fields)this.ViewSate["FieldList"]
the right type
ArrayList colFields = (ArrayLiist) this.ViewState["FieldList"];

why? how to solve it? and how to read it directly?


Nov 18 '05 #1
1 1318
I have the same issue, but in VB.Net. In my attempts to solve it, I modified
the class as follows, but that didn't change the behavior:

<Serializable()> public class Fields
inherits ArrayList
implements ISerializable

private sString as String
private nInt as Int

public sub New()
end sub

public sub New( byval info as Serializationinfo, byval c as
streamingcontext)
' get variables from info
end sub

sub getobjectdata(byval info as Serializationinfo, byval c as
streamingcontext) implements Iserializable
'save variables to Info
end sub
end class

"leal ting" <le******@hotmail.com> wrote in message
news:uw**************@TK2MSFTNGP10.phx.gbl...
a class inherited from ArrayList,
is saved to ViewState,
why the type of the object read from ViewSate is not the class,
but the parent, ArrayList
[my email address le******@hotmail.com]
the class inherited from ArrayList

public class Fields: ArrayList
{
public Fields()
{}
}
Save to ViewState
this.ViewSate["FieldList"] = colFields;

when reading, it raises an error,
Fields colFields = (Fields)this.ViewSate["FieldList"]
the right type
ArrayList colFields = (ArrayLiist) this.ViewState["FieldList"];

why? how to solve it? and how to read it directly?

Nov 18 '05 #2

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

Similar topics

10
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
6
by: Max | last post by:
I need an vb.net class that is invoked from aspx page, that use the viewstate/session object. This class must be store the information into viewstate/session. Can you give me an example ? Thanks
5
by: Steve Richter | last post by:
In my user control I want to read the ViewState dictionary of the Parent control. But this sensible idea is not permitted by the compiler: Compiler Error Message: CS1540: Cannot access...
6
by: Brad | last post by:
I am creating a class (not a control) which implements IStateManager. I've created the class and all of the implementations (LoadView, SaveViewState, etc...). My Question is: How do I...
16
by: Dennis | last post by:
I have a class named "myclass" and an arraylist containing elements of type "MyClass". I want to get the value of a property of "MyClass" (a string type) for one of the arraylist elements. I...
14
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
14
by: cweisbrod | last post by:
All, I'm seeing something very strange and was hoping someone might have some insight into the cause of what I'm seeing. I have the following scenario: Platform: Microsoft Windows XP Pro,...
1
by: David Lozzi | last post by:
Howdy, A little background, using asp.net 2.0, i'm using a wizard object to create a email interface for a user to email out their clientele, about 200 or so, depending on the selection. The...
18
by: RB | last post by:
Hi guys (and gals!), I've got 2 classes, "TypesafeConstant" and "Color". "Color" inherits from "TypesafeConstant", and adds no new functionality. All "Color" does is to instantiate some class...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.