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?
Sep 29 '09
13 2780
Hi again, i did another alternative -
<%ArrayList list2 = (ArrayList)Session["horse"];%>
-
<table cellpadding=0 cellspacing=11>
-
<tr>
-
<td>
-
<fb:profile-pic uid="<%=list2[0]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[1]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[2]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[3]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[4]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
-
</tr>
-
<tr>
-
<td>
-
<fb:profile-pic uid="<%=list2[5]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[6]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[7]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[8]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
<td>
-
<fb:profile-pic uid="<%=list2[9]%>" facebook-logo="true" width="50" height="50"linked="true" />
-
</td>
-
-
</tr>
-
</table>
-
But it has an error saying Index was out of range. Must be non-negative and less than the size of the collection. I know in my sql there are only 6 uid, How do i make the array or arraylist size unlimited?
Plater 7,872
Recognized Expert Expert
If there are only 6 entries, why would you think doing list2[9] would work?
Yea! i did it!
Now it works -
-
-
</form>
-
<div>
-
<table cellpadding=0 cellspacing=11>
-
<tr>
-
<%ArrayList mylist = (ArrayList)Session["horse"];%>
-
<%for (int i = 0; i < list2.Count; i++)%>
-
<%{ %>
-
<td>
-
<fb:profile-pic uid="<%=mylist[i]>" facebook-logo="false" width="50" height="50"linked="true" />
-
</td>
-
<%}%>
-
</tr>
-
</table>
-
</div>
-
-
-
haha, but it gives me one row only does anyone know how to split my pic
like
pic 1, pic 2, pic 3
pic 4, pic 5, pic 6
Plater 7,872
Recognized Expert Expert
Just start doing the math out?
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
| |