Adding columns dynamically

A

Anonymous

Hey,

I am adding a column dynamically to a datagrid, with
the following code:

Dim objTC As New TemplateColumn
objTC.ItemStyle.Width = Unit.Percentage(2)
objTC.ItemTemplate = New ExpandCollapseButtonTemplate
Columns.Add(objTC)

' the class for the column
Private Class ExpandCollapseButtonTemplate
Implements ITemplate

Sub InstantiateIn(ByVal container As Control)
Implements ITemplate.InstantiateIn
' create the image button for the +/- image
' and define the parameters
Dim btnExpand As New ImageButton
btnExpand.ImageUrl = "~/Images/Plus.gif"
btnExpand.ID = "btnExpand"
btnExpand.EnableViewState = True
btnExpand.CommandName = "Expand"

' add the imagebutton to the parent which is
our
' datagrid and here defined as container.
container.Controls.Add(btnExpand)

End Sub
End Class

This adds a new button in each row for the first cell.
However it adds the button for Item and AlternatingItem,
But Now I would like to add something else for the
alternatingItem. Any idea how I can do that?

Thanks
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top