473,500 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Unable to cast object of type 'System.String' to type 'System.String[]'."

28 New Member
hi
i'm using the following statement in my application
string[] strTArray = new string[5];
strTArray = (string[])(Session["TextDataArray"]);

when i run the application its giving the below error

{"Unable to cast object of type 'System.String' to type 'System.String[]'."}


can anyone say how to solve this
thanks in advance
Archu
Oct 5 '07 #1
4 11262
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
That session variable does not store a string array.
that is what .net means by throwing that error.

cheers.
Oct 5 '07 #2
archu007
28 New Member
hi
but i want to use that as i'm creating dynamic controls i want to store their values
is there any other way to do that


That session variable does not store a string array.
that is what .net means by throwing that error.

cheers.
Oct 5 '07 #3
Plater
7,872 Recognized Expert Expert
yes.
store your data as a single string.
since textboxes keep their data as a single string it should be fairly simple to do.
Oct 5 '07 #4
numena79
4 New Member
Why don't you try using an Arraylist (or more specifically a Generic List) for your input instead?

If you have not choice but to store your input in a string[] , see if this works,

//this would be your original input array
string[] arrayinput = new string[] { "hello", "world" };

//convert it to a generic list of strings
List<string> test = new List<string>(arrayinput);

//store the above list in session
Session["test"] = test;

//retrieve the list from the session into an string[] array
string[] testarray = ((List<string>)Session["test"]).ToArray();

Kind of circuitous, but it would get the job done.

Thanks.
Oct 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
7359
by: Pankaj Jain | last post by:
Hi All, I have a class A which is derived from ServicesComponent to participate in automatic transaction with falg Transaction.Required. Class A is exposed to client through remoting on Http...
0
1422
by: raca | last post by:
I am trying to create a generic SOA ServiceInvoker that will accept an XML string that will be used to deserialize an object generated by XSDObjectGen. The hierarchy goes like this:...
4
3807
by: Mike Cooper | last post by:
There is something about inherited classes I evidently don't know... I wrote the following class: Class Class1 inherits System.Windows.Forms.DataGridTextBoxColumn End Class There is...
0
11210
by: Aryeh Holzer | last post by:
Hi, I've been trying to use the weather webservice available from the National Weather Service (NWS), at http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML. wsdl without success. Here's...
0
1227
by: Amil | last post by:
I've upgrade to VS 2005. I have several pages that dynamically load user controls; I get an exception like: "Unable to cast object of type 'ASP.xxxxx' to type" I've investigated and found...
4
2447
by: JackBlack | last post by:
Hi, all! Need a little help tracking down a runtime error problem. I'm getting this error: "Unable to cast object of type 'myStruct' to type 'myStruct'... but the two types are identical! I...
10
7509
by: R2d2Rabeau | last post by:
Hi, I'm new to C#, please be patient :-) I am trying to pass an Arraylist (myAL) to a jagged array (myAL2) . The problem I have is that when I write the values to a file i do not get the values...
1
10506
by: Martin Plechsmid | last post by:
Hello, (After investigating my real problem) I've got a C# web service containing a single method: public MyBDO Test() { return null; }
2
10778
by: anj2k5 | last post by:
I uploaded music file in SQl DB in a image dataype .But when i try to reterive it,It doesn't play. It gives the following type casting error on runtime "Unable to cast object of type...
0
7136
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
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.