Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Get Info from ArrayList

Author  Topic 

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-12-16 : 09:34:27
public static ArrayList RetrievePropertyImages(string PropertyID)
{
PropertyApp.PropertyImages myPropertyImages = new PropertyApp.PropertyImages();
ArrayList myList = new ArrayList();

try
{
SqlDataReader r = GetPropertyImages(PropertyID);
while (r.Read() == true)
{
myPropertyImages.PropertyImageID = r["PropertyImageID"].ToString();
myPropertyImages.PropertyImageType = r["PropertyImageType"].ToString();
myPropertyImages.PropertyImageTypeID = r["PropertyImageTypeID"].ToString();
myPropertyImages.PropertyID = r["PropertyID"].ToString();
myPropertyImages.PropertyPictureDescription = r["PropertyPictureDescription"].ToString();
myPropertyImages.PropertyImage = r["PropertyImage"].ToString();
myPropertyImages.Rank = r["Rank"].ToString();
myPropertyImages.IsDefault = r["IsDefault"].ToString();
myPropertyImages.DateAdded = r["DateAdded"].ToString();
myPropertyImages.IsDeleted = r["IsDeleted"].ToString();
myList.Add(myPropertyImages);
}
r.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
PropertyApp.ErrorLog.LogError(e.Message.ToString(), e.Message.ToString() + " Error in RetrievePropertiesImages Method");
}
finally
{
if (Conn.State == ConnectionState.Open)
{
Conn.Close();
}
}
return myList;
}

How do I retrieve the above data individually ?

eg PropertyImageID, PropertyImageType etc

Note I am not binding to any datasource


If it is that easy, everybody will be doing it

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-16 : 09:55:13
what do you mean by individually?



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-12-16 : 10:36:50
How do I retrieve the data ?
ArrayList myList = PropertyApp.PropertyImagesDal.RetrievePropertyImages("15");
Response.Write("xxxxxxxxxxxxxxxxxxxxx" + myList.Count.ToString());
for (int index = 0; index < myList.Count; index++)
{
Response.Write("<br> -- "+myList[index].ToString());
}

If it is that easy, everybody will be doing it
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-12-16 : 11:06:39
When you put stuff into an ArrayLIst, it has a class. When you take them back out, you need to cast them back to the same class. It appears that your arrayList has items of the class PropertyApp.PropertyImages in them, so just cast them to that class when you retrieve them, and then you can access the properties.

you can either do this:

foreach (PropertyApp.PropertyImages img in myList)
{
// img now contains a reference to each item in your list
}

or something like:

PropertyApp.PropertyImages img;
for (int index=0; index < myList.Count; index++)
{
img = (PropertyApp.PropertyImages) myList[index];
}

As usual, when I see questions like this, it makes me concerned that basic concepts of the language being used aren't well known, so I strongly recommend taking some time to read a good book on C# to get a grasp on some of the basics. Casting to proper datatypes and using ArrayLists are pretty core concepts to using C#.



- Jeff
Go to Top of Page

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-12-21 : 01:00:55
tHANSK JSMITH

If it is that easy, everybody will be doing it
Go to Top of Page
   

- Advertisement -