Technology Microsoft Software & solutions

How to Use the Select Command in the DataGrid in Asp.net

    • 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
RELATED POSTS on "Technology"
How to Configure Oracle 10G for XP Home
How to Configure Oracle 10G for XP Home
How to Use Glass Bottles to Make Windows
How to Use Glass Bottles to Make Windows
What Is Windows Sharepoint Services 3.0?
What Is Windows Sharepoint Services 3.0?
How to Uninstall the Computer Associates eTrust Agent
How to Uninstall the Computer Associates eTrust Agent
How to Boot to Safe Mode on an HP Pavilion dv6000
How to Boot to Safe Mode on an HP Pavilion dv6000
How to Unzip Files in Windows 98
How to Unzip Files in Windows 98
How to Remove Spy.Goldun
How to Remove Spy.Goldun
How to Get Rid of the Trial Period for Adobe Lightroom
How to Get Rid of the Trial Period for Adobe Lightroom
Kindle for PC Installation Problems
Kindle for PC Installation Problems
How to Clean Spyware From the Registry
How to Clean Spyware From the Registry
How to Add Windows XP to Your Laptop
How to Add Windows XP to Your Laptop
How to Uninstall a Paper Port
How to Uninstall a Paper Port
What is Active Sync for X50?
What is Active Sync for X50?
How to Upgrade Windows SharePoint Services
How to Upgrade Windows SharePoint Services
How to Get Windows to Start in an Administrator Account
How to Get Windows to Start in an Administrator Account
How do I Create Restore Diskette for XP?
How do I Create Restore Diskette for XP?
How to Avoid a Cyclic Redundancy Check
How to Avoid a Cyclic Redundancy Check
What Are the Keystrokes for Pasting?
What Are the Keystrokes for Pasting?
How to Make Windows Vista Stop Looking for New Wireless Networks
How to Make Windows Vista Stop Looking for New Wireless Networks
Recommended Hardware Requirements for Running Vista Home
Recommended Hardware Requirements for Running Vista Home

Leave Your Reply

*