views:

1066

answers:

1

I want to add a row to that will contain dropdowns,search textboxes, and maybe other controls to allow filtering to the gridview. I've looked at This Question but it did not help me. How can I add a row so i can add these controls to my gridview?

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim cell As New TableCell
    Dim ddloper As New DropDownList

    If e.Row.RowType = DataControlRowType.Header Then
        Dim row As New GridViewRow(-1, -1, DataControlRowType.Header, DataControlRowState.Normal)

        For Each c As DataControlField In CType(sender, GridView).Columns
            Dim nc As New TableCell
            nc.Text = c.AccessibleHeaderText
            row.Cells.Add(nc)
        Next
        'e.Row.Parent.Controls.AddAt(-1, row)

    End If
end sub
+1  A: 

Here's what i did.

 Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
    Dim row As New GridViewRow(-1, -1, DataControlRowType.Header,DataControlRowState.Normal)

    GridView1.Rows(2).Parent.Controls.AddAt(0, row)



end sub
Eric