DataGrid Web Control Depth Adventures (3) Part2

zhaozj2021-02-16  52

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: