Add INSERT in DataGrid

xiaoxiao2021-03-06  39

We didn't see the Insert option in the property of DataGrid. Only SELECT / EDIT, UPDATE, CANCEL / DELETE three options, how do we implement our INSERT function? My approach is like this, join a SELECT (Button Colombn), Setting its text / command name attribute is INSERT. As shown below

I believe that this step will understand a lot of stuff, you can join multiple such linkbutton to achieve a lot of the features you want. There are not many words here, leave them to you. ^ _ ^ Questions The writing of the background code. How to deal with the event we just set up?

In DataGrid's event, we found that there is carativecommand / updateCommand / editcommand / updateCommand but there is no INSERTCOMMAND and SELECTCOMMAND, what should I do? It doesn't matter, is it a ItemMand? We use this. Private Sub grdColor_ItemCommand (ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdColor.ItemCommand Select Case e.CommandName.ToLower.Trim Case "insert" ...... 'Here we can write down our operations for INSERT. End select End Sub Here, our INSERT feature is completed. ^ _ ^ You can also simulate this more you want.

转载请注明原文地址:https://www.9cbs.com/read-54399.html

New Post(0)