how to add an buttonColumn to a datagrid by vb-code ?
Why is it that when I put this into my aspx-page :
<asp:datagrid id="myDataGrid_todayConsumptions"
<Columns>
<asp:ButtonColumn Text="EventName" CommandName="myEvent"></asp:ButtonColumn>
</Columns>
</asp:datagrid>
and the user clicks on these buttoms this is fired up (as I want it to do) :
VB Code:
Private Sub todo(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs) Handles myDataGrid_todayConsumptions.ItemCommand
Dim test As String = "xxx"
End Sub
but not if I add the buttonColumn by vb-code like this.
VB Code:
Dim myButtonColumn As ButtonColumn = New ButtonColumn
myButtonColumn.Text = "EventName"
myButtonColumn.CommandName = "myEvent"
myDataGrid_todayConsumptions.Columns.Add(myButtonColumn)
It is desperating - I need to add the ButtonColumn by vb-code, but I does not work like it does if I add it into the aspx-page code.
I do not understand why...
Thank you very much for any advice!