asp.net: Composite Control with GridView

P

Patrick

Hello

I try to make a composite control which contains a GridView. My problem is
now, how do I add the <Columns> to this Gridview. I can do
myGridView.Columns.Add(), but it asks for a DatacontrolField, but I didn't
figure out how to create a DataControlField for the following entry:

<asp:CommandField ShowDeleteButton="True" />

<asp:BoundField DataField="UserId" HeaderText="User Id" ReadOnly="True" />

<asp:BoundField DataField="UserName" HeaderText="User Name" />



Can someone help?

Thanks
 
T

Teemu Keiski

Hi,

DataControlField is just base class for GridView fields such as BoundField.
Therefore you'd need to instantiate these columns as separate objects (with
these derived types) in code and add to the Columns collection.

What you showed was example of the declarative syntax which can be used on
aspx/ascx etc, however it doesn't apply in code. You can parse content from
markup (string) using Page.ParseControl however, it doesn't provide the same
(Intellisense etc features provided by the IDE) which you get if you
instantiate them in code.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,282
Latest member
RoseannaBa

Latest Threads

Top