Hi, i am having a problem as im new to c#. I did an arraylist and store my "uid" and want to put it into a row of pictures
pic 1 , pic 2 , pic 3, pic 4
this is my code for putting the "uid" the arraylist
pofile2.aspx.cs -
ArrayList list2 = new ArrayList();
-
//query to get uid
-
thesql = "select * from Student where caregroupID= @CareGroupID";
-
-
using (SqlCommand cmd = new SqlCommand(thesql, con))
-
{
-
cmd.Parameters.AddWithValue("CareGroupID", Session["caregroupID"].ToString());
-
con.Open();
-
-
using (SqlDataReader reader = cmd.ExecuteReader())
-
{
-
while (reader.Read())
-
{
-
list2.Add(reader["uid"].ToString());
-
}
-
}
-
Session["horse"] = list2;
-
con.Close();
-
}
-
I understand my Session becomes an object and so i have to cast it back.
This is my aspx page where i tried to cast it. -
<%ArrayList mylist = (ArrayList)Session["horse"];%>
-
<!--fb:fan profile_id="171381255280" name="caregroup" stream="0" connections="8" width="250"></fb:fan-->
-
</form>
-
<div>
-
<table cellpadding=0 cellspacing=11>
-
<tr>
-
<%for (int i = 0; i < 8; i++)%>
-
<%{ %>
-
<td>
-
<fb:profile-pic uid="<%=mylist[i].ToString()%>" facebook-logo="false" width="50" height="50"linked="true" />
-
</td>
-
<%}%>
-
</tr>
-
</table>
-
</div>
-
But it seems like i can't put the cast at my ASPX page. The error states the namespace arraylist does not exist, Any idea what other solution can be used?
13 2779 Plater 7,872
Recognized Expert Expert
Well your error could probably be fixed by saying System.Collecti ons.ArrayList
(or adding the System.Collecti ons namespace for it)
However, if you are interested in display tabluar data in a webpage, I recomend looking up the DataTable object(and the SqlDataAdapter to fill it), then using a GridView object to handle the table building
where do i put the System.Collecti ons.ArrayList
in my ASPX page?
Like <%System.Collec tions.ArrayList ;%>
Sorry Im really new to this
Plater 7,872
Recognized Expert Expert
I would go to the code file, since the exception is probably on the line:
ArrayList list2 = new ArrayList();
And put the cursor over the first ArrayList word. A little red line will probably appear under the last letter. If you move over it, a drop down will appear allowing you to add the namespace if you want?
There is no error in the ArrayList list2 = new ArrayList(); i have all the namespace needed for the code file. But it is in my ASPX page where there is error in <%ArrayList mylist = (ArrayList)Sess ion["horse"];%>.
Hope you guys can understand me.
GaryTexmo 1,501
Recognized Expert Top Contributor
I was under the impression that Platter meant... - <%System.Collections.ArrayList myList = (System.Collections.ArrayList)Session["horse"];%>
Platter? I've never put C# code on a web page before, so maybe you can't do this...
Plater 7,872
Recognized Expert Expert
Yes Gary that is a valid way of doing it.
I think is a way to do the namespace part in the web page side as well, but i cannot remember the format
GaryTexmo 1,501
Recognized Expert Top Contributor
I did a bit of googling... does this help at all? http://msdn.microsoft.com/en-us/library/ms164642.aspx
It seems you need to put the namespace references in a web.config file somewhere. This looks like it talks about VB, but I found this same information in relation to C#... so maybe it works like this too?
As I said, I don't know much about this kind of thing, just trying to be helpful. It's definitely confusing... give me a compiler any day! ;)
Plater 7,872
Recognized Expert Expert
Are you positive its on the webpage part and not the code part?
I just threw this line in a page:
<%ArrayList mylist = new ArrayList();%>
And it accepted it just fine, no errors
Thanks guys im able to add <%ArrayList list2 = (ArrayList)Sess ion["horse"];%> right now. It is after i put <add namespace="Syst em.Collections"/> in my webconfig namespace.
But i have another problem now. My list2 in my <fb:profile-pic uid="<%=list2%> "
does not work. Any idea what should i put to get all the uid from the loop? -
<%ArrayList list2 = (ArrayList)Session["horse"];%>
-
<%for (int i = 0; i < 8; i++)%>
-
-
<%{ %>
-
-
<td>
-
-
<fb:profile-pic uid="<%=list2%>" facebook-logo="false" width="50" height="50"linked="true" />
-
</td>
-
-
<%}%>
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ken Allen |
last post by:
I am contemplating a rather complex inplementation that calls for a factory
class that can instantiate a large number of specific business objects, each
of which share a set of common base business rules (e.g., Update, Delete,
etc.) as well as a set of object specific methods. Of couse, all of the
interfaces shall be defined in a common assembly for the client and server
components. Since all of these are remoted, presume that the...
|
by: MattC |
last post by:
Hi,
How can do runtime casting?
MyCollection derives from ArrayList
I will store lost of different objects that all derive from the same parent
class. I then want to be able to pass in the object type and collection type
I have a number of classes that derive from ArrayList and have if pick out
on ly those i asked for.
|
by: Fred |
last post by:
I'm trying to build a hashtable and a arraylist as object value
I'm not able to retrieve stored object from the hashtable.
Hashtable mp = new Hashtable(); // THE HASHTABLE
ArrayList atemp = new ArrayList(); // THE ARRAY
StreamWriter sw = new StreamWriter(@"C:\temp\fred.html");
|
by: Stephane |
last post by:
Hi,
I want to keep a list of my visitors in an ArrayList which I place in the
application object like this:
Application("Visitors") = new ArrayList(); // The list of visitors
Then, each visitors update their own information in that list for every page
they visit.
|
by: Jon the Blind |
last post by:
I have a set of business object classes built from the typed dataset tool in
Visual Studio. Since the individual objects (such as the Order object, for
example) inherit from DataRow, a common requirement is to cast an array of
DataRows to an array of Orders. But I keep getting InvalidCastExceptions
when I do this, for example:
Dim orders As Order() = CType(RowsAffected, Order())
In this example, RowsAffected returns an array of...
| |
by: Joe |
last post by:
Hello All:
I am writing a function which accepts an ArrayList as its parameter and
converts the contents of the ArrayList into an XmlNodeList. The ArrayList
will contain one of several different structures. For example, the
structures could be either a Customer structure (which contains a customer id
and name) or an Address structure (which contains an address type and street
number, city, etc). The XmlNodeList is uded to populate a...
|
by: Andy Chen |
last post by:
Hi,
I have a Hashtable, key is string and value is ArrayList. The problem is I
cannot cast the value from object to ArrayList.
like this:
Hashtable ht = new Hashtable();
ArrayList al = new ArrayList();
al.Add("test");
ht.Add("key1", al);
|
by: mijobee |
last post by:
Hello Everyone,
I just wanted to check that I'm using dynamic_cast correctly. I have a
hierarchy of objects using pure virtual classes and virtual inheritance
to implement interfaces. I ran into a problem using C-style casting to
an instance of a derived class from its interface type to a variable of
its concrete type. I was confused because I thought C-style casts
always compiled even if they wouldn't run correctly at runtime. I...
|
by: Ralph |
last post by:
Hi
I don't understand why it's not working:
function schedule(imTop){
this.tdImagesTop = imTop;
}
schedule.prototype.selectEl = function() {
alert(this.tdImagesTop);
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |