- 1). Create a DataGrid instance by dragging and dropping a DataGrid onto your Asp.net page from Visual Studio's Toolbox.
- 2). Modify the DataGrid in code by typing the following, for example, in your code-behind file:
MyDataGrid.ShowFooter= True - 3). Attach an event handler in your ASP or ASPX code per the following example, which attaches the "MyEditEventHandler" to the DataGrid's edit event.
<asp:DataGrid OnEditCommand="MyEditEventHandler"/> - 4
Tell Asp.net what to do when a user clicks on the DataGrid's "Edit" button.Jupiterimages/Polka Dot/Getty Images
Attach a method to the DataGrid's edit button. Access its click event to manually control the DataGrid's behavior. Press any of the DataGrid's auto-generated "edit" buttons on a live web page to trigger the event.
'Tell the DataGrid to run the MyDataGrid_Edit function when the
'MyDataGrid Edit Command is triggered
AddHandler MyDataGrid.EditCommand, AddressOf MyDataGrid_Edit - 5). Add a method to execute when the user triggers the "Select" command.
'Create the MyDataGrid_Edit command
Sub MyDataGrid_Edit(sender As Object, e As DataGridCommandEventArgs)
'Code to execute when the user hits the edit button
End Sub - 6). Change the color of an item in your ASPX code by assigning a string to its Backcolor property. Retrieve and edit the style of the selected item in a DataGrid control to fit your design specification.
<EditItemStyle BackColor="red"> </EditItemStyle>
SHARE