how to add programmatically a boundfield to a gridview?

  • Thread starter Thread starter michel
  • Start date Start date
M

michel

Hi,

I want to add programmatically a boundfield to a gridview:

<asp:GridView ID="GridView1" runat="server">
<Columns>
</Columns>
.....
</asp:GridView>

code-behind:
-----------------
Dim bf As new BoundField
GridView1.Controls.Add(bf)

this gives the error:
"Value of type 'System.Web.UI.WebControls.BoundField' cannot be converted to
'System.Web.UI.Control"

Thanks for help
Michel
 
i found it:

Dim bf As BoundField
bf = New BoundField
bf.DataField = "fld"
GridView1.Columns.Add(bf)
 
Back
Top