DataGrid Itemcreated and ItemDatabase Events use tips!

xiaoxiao2021-03-06  47

DataGrid's events, ItemCreated and ItemDatabase are particularly important and often used, where the itemcreated event triggers when DataGrid creates a table row, and ItemDatabase is bound to the corresponding row, the former is triggered in the data binding. You can use a dynamic control in the DataGrid, such as adding a button in the DataGrid's title row, and the itemDatabase is triggered, and the data has been bound to the corresponding line, then you can Get the data of the current line, and perform the corresponding operation based on this, such as the Book value of the binding to the "Sex" field with String, selected status, etc., examples, examples, examples The code is as follows, saved as an ASPX file and placed in the virtual directory:

<% @ Page language = "c #" Debug = "true"%> <% @ import namespace = "system"%> <% @ Import namespace = "system.data"%>