Checking for items in an Arraylist

G

Guest

Im trying to carry work out an else if clause in the below method but i'm
having a lot of difficulty getting the correct code which allows me to check
and see if an arraylist items has text in it containing Address not supplied.
Im trying to do something below but its not working properly. Can someone
help me do this please. the code i use is below.

private void checkArrayList()
{
ArrayList alSearchaddress;
alSearchaddress = (ArrayList) ViewState["Addresses"];
string test = "Address not supplied";

if(dgSearchAddresses.Items.Count == 0)
{
this.pnlSearchAddresses.Visible = false;
}

//******** else if(alSearchaddress[0] == test)********//
{
this.pnlSearchAddresses.Visible = false;
}

else
{
this.pnlSearchAddresses.Visible = true;
this.lblMessage.Text = "";
}
}

Arraylist is being created like so: -

Address newAddress = new Address();
newAddress.Address1 = "Address not supplied";
newAddress.Address2 = null;
newAddress.Address3 = " ";
newAddress.Address4 = null;
newAddress.Address5 = null;
newAddress.Address6 = null;
 
J

Jon Skeet [C# MVP]

<snip>

Please see my response in the .general group - there's no need to
multi-post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top