Hi,
I have on an aspx page about 16 detailsView controls. Some are 4 rows deep, some 3 and some 2. The problem I have is that the code is immense because i am setting properties of various rows ie. text size and backcolor depending on the text status of the row. To try and cut down on code I am trying to write a class or a function to detect whether the details view is 2,3,or 4 rows deep, this could be assigned manually however. The main part of the function would encompass the following i.e
DetailsView1.Rows[3].Font.Size = 8;
protected void XX_DataBind(object sender, EventArgs e)
{
if (DetailsView1.Rows[3].Cells[1].Text == "No Fault" && DetailsView4.Rows[0].Cells[1].Text == "aa")
{
DetailsView1.BorderColor = Color.LawnGreen;
}
}
if (DetailsView1.Rows[3].Cells[1].Text != "No Fault" && DetailsView4.Rows[0].Cells[1].Text == "bb")
{
DetailsView1.BorderColor = Color.Yellow;
DetailsView1.Rows[3].BackColor = Color.Yellow;
DetailsView1.Rows[0].BackColor = Color.Yellow;
DetailsView1.Rows[1].BackColor = Color.Yellow;
DetailsView1.Rows[2].BackColor = Color.Yellow;
DetailsView1.Rows[3].ForeColor = Color.Red;
}
There would be many more conditions in the lines above , and I am trying to replace the DetailsView1 with a generic DetailsView? in a function / class etc?
Hope this is clear, any help would be great, thanks- Harry