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.
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.DataSource = sdsPlanningTable
Private Sub dgPlanningTable_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgPlanningTable.ItemCommand
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.
Pat Phelan, I expected to display the message on the workstation machine which at this point in development happens also to be the server machine.
Teddy, you're right, I am using ASP.NET. I had a bit of a look at the link from Pat (probably less than it deserved.) but I did not really find the solution I was looking for.
You were correct that the controls I created during runtime were lost on postback. That in fact was the cause of my problem.
I have since switched to a gridview and started using an empty gridview created in the default.aspx file instead of a placeholder and found that it does not disappear when triggering an event for a control that exists within the gridview. Furthermore the event itself fires allowing me to do what I need to.