gridview row border

4.3k Views Asked by At

I have a gridview which is data bounded. i want that every time data is bound the the border color and width of some rows will change. i wrote this function:

protected void GridView1_DataBound(object sender, EventArgs e)
{   
    int column = 3;
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
        string current = GridView1.Rows[i].Cells[column].Text;
        string next;
        if (i+1 < GridView1.Rows.Count) next = GridView1.Rows[i + 1].Cells[column].Text;
        else return;

        if (current != next)
        {
            GridView1.Rows[i + 1].Style[HtmlTextWriterStyle.BackgroundColor] = "#FFFF00";

            GridView1.Rows[i + 1].Style.Add(HtmlTextWriterStyle.BorderWidth, "20px");
            GridView1.Rows[i + 1].Parent.
            GridView1.Rows[i + 1].Style.Add(HtmlTextWriterStyle.BorderColor, "#000000");

        }
    }

}

the problem is that the background color works but the border doesn't.. how can i give the row border width and color ?

Thanks :-)

I Solved it myself:

    protected void GridView1_DataBound(object sender, EventArgs e)
{           
    int column = 3;
    string current;
    string next;
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
        current = GridView1.Rows[i].Cells[column].Text;
        if (i+1 < GridView1.Rows.Count) next = GridView1.Rows[i + 1].Cells[column].Text;
        else return;

        if (current != next)
        {
            //GridView1.Rows[i + 1].Style.Add(HtmlTextWriterStyle.BackgroundColor, "#FFF200");
            GridView1.Rows[i].Attributes["style"] = "border-top-style:none; border-bottom-style:solid; border-left-style:none; border-right-style:none; border-color:Black;";
        }
    }     
}

but it's not working on IE, in chrome it does..

0

There are 0 best solutions below