Extended the gridview control to add multiple common functions)

Source: Internet
Author: User
[Last updated: 2007.09.03]
The gridview is powerful and easy to use. To make it more powerful and easy to use, we can write a control that inherits from the gridview.
[Source code download (C #)]
[Source code download (VB)] thanks to Dr. Lang for providing the vb version Article address

Extended gridview control (INDEX)-added multiple common functions

Author: webabcd

/* Implementation of the official version */

Article Index
Extend the gridview Control (1)-change the row style when the mouse goes through the row
Extended gridview Control (2)-composite sorting and sorting status prompts
Extended gridview control (3)-set its client properties according to the commandname of the button
Extend the gridview control (4)-linkage check box (select all and deselect all of the check boxes)
Extend the gridview control (5)-fixed the specified row and column
Extended gridview control (6)-response row Click Event and double-click event
Extend the gridview control (7)-change the row style when the row's specified check box is selected
Extend the gridview control (8)-export data from a data source to Excel, Word, or text
Extend the gridview control (9)-Add a right-click menu to the data row
Extended gridview control (10)-custom Page Style
Extend the gridview control (11)-merge adjacent cells with the same content in the specified Column
Note: Except for "fixed specified rows and columns", only Internet Explorer and Internet Explorer are supported.

Widget

Control usage
1. Change the style of the row when the mouse goes through the row, and restore the style of the row when the mouse leaves the row.
Usage (set attributes ):
Mouseovercssclass-CSS Class Name of the row when the cursor goes through

2. Composite sorting of multiple fields; prompt for sorting status in ascending or descending order
Usage (set the smartsorting compound attribute ):
Allowsorttip-whether to enable sorting prompt
Allowmultisorting-whether to enable composite sorting
Sortascimageurl-indicates the URL of the image in ascending order (use the default image if not set)
Sortdescimageurl-indicates the image URL in descending order (use the default image if not set)
Sortasctext-Prompt text in ascending order
Sortdesctext-Prompt text in descending order

3. Set the client properties according to the commandname of the button.
Usage (set clientbuttons set attributes ):
Boundcommandname-commandname to be bound
Attributekey-attribute name
Attributevalue-attribute value (two placeholders: {0}-commandargument; {1}-text)
Position-position of the attribute value

4. Linkage check box (select all or cancel all of the check boxes ). If you select the specified parent check box, set all the specified child check boxes to the selected status. If you deselect the specified parent check box, set all the specified child check boxes to the deselected status.
Usage (set cascadecheckboxes set attributes ):
Parentcheckboxid-parent checkbox ID in the template Column
Childcheckboxid-subcheck box ID in the template Column
Static Method in yycontrols. helper. smartgridview
List Getcheckeddatakey (gridview GV, int columnindex)
List Getcheckeddatakey (gridview GV, string checkboxid)

5. Fixed specified rows and columns, fixed Rows Based on rowtype, and fixed Rows Based on rowstate
Usage (set the fixrowcolumn compound attribute ):
Fixrowtype-rowtype of the row to be fixed (separated by commas)
Fixrowstate-rowstate of the row to be fixed (separated by commas)
Fixrows-index of rows to be fixed (separated by commas)
Fixcolumns-index of columns to be fixed (separated by commas)
Tablewidth-table width
Tableheight-table height

6. Respond to the row Click Event and double-click event, and process the event on the server.
Usage (set attributes ):
Boundrowclickcommandname-commandname to be bound to the row Click Event
Boundrowdoubleclickcommandname-commandname to be bound to the double-click event of a row

7. Change the style of the row when the checkbox is selected, and restore the style of the row when the checkbox is deselected.
Usage (set the checkedrowcssclass compound attribute ):
Checkboxid-check box ID of the Data row in the template Column
Cssclass-CSS Class Name of the selected row

8. Data from the exported data source is Excel, Word, or text (the data source type must be datatable or dataset)
Usage:
Method added for smartgridview
Export (string filename)
Export (string filename, exportformat)
Export (string filename, exportformat, encoding)
Export (string filename, int [] columnindexlist, exportformat, encoding)
Export (string filename, int [] columnindexlist, string [] headers, exportformat, encoding)

9. Right-click the data row to respond to server events or hyperlinks.
Usage (set contextmenus set attributes ):
Text-menu text content
Boundcommandname-commandname to be bound
Navigateurl-link URL
Target-target window or framework of The Link
Properties of smartgridview contextmenucssclass-CSS Class Name of the cascading style table in the right-click menu (Structure Div ul Li a in the right-click menu)

10. Customize the paging style. Displays the total number of records, number of records per page, current page number, total page number, home page, Previous Page, next page, last page, and pagination button
Usage (set custompagersettings compound attribute ):
Pagingmode-Display Mode of custom pages
Textformat-custom page text display style (four placeholders: {0}-number of records displayed on each page; {1}-Total number of records; {2}-current page number; {3}-Total number of pages)

11. Merge adjacent cells with the same content in the specified Column
Usage (set attributes ):
Mergecells-index of the columns whose cells need to be merged (separated by commas)

/* Implementation of the official version ends */

Address: http://www.cnblogs.com/webabcd/archive/2007/02/04/639830.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.