Hello I am using VS.net 2008
I have created a page which has a datagrid which is loaded into a placeholder with button columns that are added dynamically during runtime. I cannot however trigger an event when the buttons are clicked.
Below is a simplified version of the code I am using.
Code:
Public WithEvents dgPlanningTable As New System.Web.UI.WebControls.DataGrid()
Private Sub cmdPlanning_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPlanning.Click
Dim BCSeriesShort As New System.Web.UI.WebControls.ButtonColumn()
BCSeriesShort.HeaderText = "SeriesShort"
BCSeriesShort.CommandName = "ItemCommand"
BCSeriesShort.ButtonType = ButtonColumnType.PushButton
BCSeriesShort.DataTextField = "SeriesShort"
dgPlanningTable.Columns.Add(BCSeriesShort)
dgPlanningTable.DataSource = sdsPlanningTable
dgPlanningTable.DataBind()
PlaceHolder.Controls.Add(dgPlanningTable)
End Sub
Private Sub dgPlanningTable_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgPlanningTable.ItemCommand
MsgBox("ItemCommand")
End Sub
Obviously I will want it to do more than just say "ItemCommand" but I can't do anything until the event itself is triggered.
I have tried endless different ways to do this that I have read from endless different pages. Each seems to either deal with a problem slightly different to mine, deal with a different language or have an annoyingly incomplete code snippet that is utterly useless.
If anyone can suggest anything that might fix this problem, I might be able to stop tearing my hair out.