我想添加一行,其中包含下拉列表,搜索文本框以及其他可能允许过滤到gridview的控件。我看过This Question,但它对我没有帮助。如何添加一行,以便将这些控件添加到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
答案 0 :(得分:2)
这就是我所做的。
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