Let some things happen when you click the button
Now add the button to the DataGrid, we want to associate the code from the server side with the button so that some actions can occur when the button is clicked. When you recognize the ButtonColumn button in the DataGrid, the ItemMand event will be triggered, then we can write the server-side event handler for this event. This event handler must be defined as follows:
Sub EventHandlerName (Sender As Object, E AS DataGridCommandeventArgs ... End Sub
Once this procedure is defined in the server-side code block (or code post page), you can link DataGrid's events with the event handler by adding an onItemComman property in the DataGrid tag, as follows:
The following code demonstrates that the event handler is running when a button in the DataGrid is pressed:
SUB Page_Load (Sender As Object, E as Eventargs)
IF not page.ispostback then
Binddata () 'Only Bind The Data on The First Page Load
END IF
End Sub
Sub binddata ()
'Make a connection to the database
'DataBind The DataReader Results to The DataGrid.
End Sub
Sub detailsclicked (Sender As Object, E AS DataGridCommandeventArgs)
Response.write ("You Clicked One of the Details Buttons!")
End Sub
script>