havey
09-24-2007, 05:42 PM
hi i have a bunch of these in a for loop:
for (int index = 0; index < listpc.Count; index++)
{
if (Session["High Salt Diet"] != null && Session["High Salt Diet"].ToString() == "a" && listpc[index].PieLabel == "High Salt Diet")
{
Response.Write("<slice title='" + listpc[index].PieLabel + "' color='" + listpc[index].PieColour + "' pull_out='true' description='" + listpc[index].PieLabel + "'>" + listpc[index].PieSlice + "</slice>");
a1 = 1;
}
if (Session["High Total Cholesterol"] != null && Session["High Total Cholesterol"].ToString() == "a" && listpc[index].PieLabel == "High Total Cholesterol")
{
Response.Write("<slice title='" + listpc[index].PieLabel + "' color='" + listpc[index].PieColour + "' pull_out='true' description='" + listpc[index].PieLabel + "'>" + listpc[index].PieSlice + "</slice>");
a1 = 1;
}
if (Session["Home Stress"] != null && Session["Home Stress"].ToString() == "a" && listpc[index].PieLabel == "Home Stress")
{
Response.Write("<slice title='" + listpc[index].PieLabel + "' color='" + listpc[index].PieColour + "' pull_out='true' description='" + listpc[index].PieLabel + "'>" + listpc[index].PieSlice + "</slice>");
a1 = 1;
}
}
In every case the session["name"] equals the listpc[index].PieLabel
So i'm wondering if this can be simplified ? Thanks
for (int index = 0; index < listpc.Count; index++)
{
if (Session["High Salt Diet"] != null && Session["High Salt Diet"].ToString() == "a" && listpc[index].PieLabel == "High Salt Diet")
{
Response.Write("<slice title='" + listpc[index].PieLabel + "' color='" + listpc[index].PieColour + "' pull_out='true' description='" + listpc[index].PieLabel + "'>" + listpc[index].PieSlice + "</slice>");
a1 = 1;
}
if (Session["High Total Cholesterol"] != null && Session["High Total Cholesterol"].ToString() == "a" && listpc[index].PieLabel == "High Total Cholesterol")
{
Response.Write("<slice title='" + listpc[index].PieLabel + "' color='" + listpc[index].PieColour + "' pull_out='true' description='" + listpc[index].PieLabel + "'>" + listpc[index].PieSlice + "</slice>");
a1 = 1;
}
if (Session["Home Stress"] != null && Session["Home Stress"].ToString() == "a" && listpc[index].PieLabel == "Home Stress")
{
Response.Write("<slice title='" + listpc[index].PieLabel + "' color='" + listpc[index].PieColour + "' pull_out='true' description='" + listpc[index].PieLabel + "'>" + listpc[index].PieSlice + "</slice>");
a1 = 1;
}
}
In every case the session["name"] equals the listpc[index].PieLabel
So i'm wondering if this can be simplified ? Thanks