Add Another Footer to GridView


I came across this link to find out another approach to add another Footer to the GridView(or not show Footer)

http://hi.baidu.com/myaspdotnet/blog/item/715437ddde7b73dd8c1029d3.html

 

protected void GridView1_OnPreRender(object sender, EventArgs e)
    {
        if (GridView1.Controls.Count > 0 && GridView1.Controls[0].Controls.Count > 1)
        {
 
// //public GridViewRow(
//    int rowIndex,
//    int dataItemIndex,
//    DataControlRowType rowType,
//    DataControlRowState rowState
//)

 
GridViewRow gr = new GridViewRow(-1, -1, DataControlRowType.Footer, DataControlRowState.Normal);
TableCell cell = new TableCell();
cell.Text = "<hr style='color:yellow; height: 5px' />";
cell.Attributes["colspan"] = GridView1.Columns.Count.ToString(); //merge columns
gr.Controls.Add(cell);
//gr.Cells[0].HorizontalAlign = HorizontalAlign.Center;
GridView1.Controls[0].Controls.AddAt(GridView1.Controls[0].Controls.Count - 1, gr);
}

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s