how to add programmatically a boundfield to a gridview?

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
 
M

michel

i found it:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top