How to repeat the header template in gridivew?
<p>In asp.net, i am using gridview for displaying the data. In gridview i am displaying 300 records at a time. Now i want to display the header template after every 30 rows in gridview is it possible? can you help me. Thank you.
i write like this in gridview_rowdatabound.</p>

<pre><code>     GridViewRow row = new GridViewRow(e.Row.RowIndex, 0, DataControlRowType.Header, DataControlRowState.Normal);  
        TableCell cell = new TableCell();
        cell.Controls.Add(new Label { Text = "Header" }); //as needed              
        row.Cells.Add(cell);
        cell = new TableCell();
        cell.Controls.Add(new Label { Text = "Name" }); //as needed              
        row.Cells.Add(cell);

        cell = new TableCell();
        cell.Controls.Add(new Label { Text = "add" }); //as needed              
        row.Cells.Add(cell);

        cell = new TableCell();
        cell.Controls.Add(new Label { Text = "Nice" }); //as needed              
        row.Cells.Add(cell);

        Table tbl = (e.Row.Parent as Table); 
        tbl.Controls.AddAt(e.Row.RowIndex * 3 + 1, row);   
</code></pre>

<p>when i place  tbl.Controls.AddAt(e.Row.RowIndex * 2 + 1, row);   it is working when i place more than 2 like 3, 4 like this, then it is throing error.</p>

<p>Thank you for all i solve the problem: </p>

<pre><code>    if (e.Row.RowType == DataControlRowType.DataRow) 
       {
        if (e.Row.RowIndex == 0)
        {
            ViewState["i"] = e.Row.RowIndex;
        }

        if (Convert.ToInt32(ViewState["i"].ToString()) == e.Row.RowIndex)
        {

            GridViewRow row = new GridViewRow(e.Row.RowIndex, 0, DataControlRowType.Header, DataControlRowState.Normal);
            TableCell cell = new TableCell();
            cell.BackColor = System.Drawing.Color.BurlyWood;
            cell.Controls.Add(new Label { Text = "header" }); //as needed              
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.BackColor = System.Drawing.Color.BurlyWood;
            cell.Controls.Add(new Label { Text = "Name" }); //as needed              
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.BackColor = System.Drawing.Color.BurlyWood;
            cell.Controls.Add(new Label { Text = "add" }); //as needed              
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.BackColor = System.Drawing.Color.BurlyWood;
            cell.Controls.Add(new Label { Text = "Nice" }); //as needed              
            row.Cells.Add(cell);
            int cnt = Convert.ToInt32(ViewState["i"].ToString());

            Table tbl = (e.Row.Parent as Table);

            //tbl.Controls.AddAt(e.Row.RowIndex * cnt , row);
             tbl.Controls.AddAt(e.Row.RowIndex, row);               

            cnt = cnt + 4;
            ViewState["i"] = cnt.ToString();

        }

    } 
</code></pre>
