|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
asp.net: Composite Control with GridViewHello
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 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.
REPOST: How can I change the color of the Selected Item in a list
IExtenderProvider TREENODETYPES attribute does not work Error: Multiple controls with the same ID a dropdown list in the "Properties" window Stack Over Flow Message in IE Calling an ASP File From ASP.net page Add UserControl on CodeBeheind Send email bu clicking button Datagrid navigation problem |
|||||||||||||||||||||||