Results 1 to 1 of 1

Thread: how to add an buttonColumn to a datagrid by vb-code ?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member fabianus's Avatar
    Join Date
    Sep 2004
    Location
    Paris
    Posts
    402

    Question 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:
    1. Private Sub todo(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs) Handles myDataGrid_todayConsumptions.ItemCommand
    2.         Dim test As String = "xxx"
    3.     End Sub

    but not if I add the buttonColumn by vb-code like this.
    VB Code:
    1. Dim myButtonColumn As ButtonColumn = New ButtonColumn
    2.         myButtonColumn.Text = "EventName"
    3.         myButtonColumn.CommandName = "myEvent"
    4.         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!
    Last edited by fabianus; May 27th, 2005 at 05:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width