1. Design Steps
(1) create a BackGround folder under the root directory of the website to store the Web forms for website BackGround management.
(2) create a new Web form in the BackGround folder named CheckInfo. aspx, which is mainly used for Free Supply and Demand Information Review.
(3) Add a Table to the Web form for page layout.
(4) Add a Label control to the Table, which is mainly used for the total number of pages after the page of the GridView control. Main attribute settings: The AllowPaging attribute is True, that is, pagination is allowed; The PageSize attribute is 24, that is, 24 data entries are displayed on each page; The AutoGenerateColumns attribute is False, that is, automatically generated columns are not displayed.
(5) add three RadioButton controls to the Table to control and display audited Supply and Demand Information, unaudited supply and demand information, and all supply and demand information of the same type.
(6) Add a GridView control to the Table to display the supply and demand information and review the supply and demand information.
2. Implementation Code
Declare Global static variables and class objects. For more information, see comments in the code. In the loading event of the page, obtain the type of supply and demand information, and call the custom GridViewBind method to query the supply and demand information of the relevant type is displayed in the GridView control. It is worth noting that all types of supply and demand information are audited on the CheckInfo. aspx page. The implementation code for page loading events is as follows:
Routine 28 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
Operation operation = new Operation (); // business layer Class Object Static string infoType = ""; // Supply and Demand Information type Static int CheckType =-1; // three types: All (-1 Show all), show not reviewed (0), show audit (1) Protected void Page_Load (object sender, EventArgs e) { If (! IsPostBack) { InfoType = Request. QueryString ["id"]. ToString (); GridViewBind (infoType ); } } |
The custom GridViewBind method is used to query Supply and Demand Information of related types and display the query results in the GridView table control. The implementation code is as follows:
Routine 29 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
/// <Summary> /// Bind the supply and demand information to the GridViev Control /// </Summary> /// <Param name = "type"> Supply and Demand Information type </param> Private void GridViewBind (string type) { GridView1.DataSource = operation. SelectInfo (type ); GridView1.DataKeyNames = new string [] {"id "}; GridView1.DataBind (); // Display the current page number LblPageSum. Text = "Current page is" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + "page "; } |
The RowDataBound event of the GridView control occurs when the data row is bound to the data. In this event, each bound row sets the related functions of each row, such as highlighting rows, Setting audit status, and using Redundant text... Replace. The implementation code is as follows:
Routine 30 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
Protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e) { If (e. Row. RowType = DataControlRowType. DataRow) { // Highlight the specified row E. Row. Attributes. Add ("onMouseOver", "Color = this. style. BackgroundColor; this. style. backgroundColor = '# FFF000 '"); E. Row. Attributes. Add ("onMouseOut", "this. style. backgroundColor = Color ;"); // Set the audit status and colors If (e. Row. Cells [5]. Text = "False ") { E. Row. Cells [5]. Text = StringFormat. HighLight ("not reviewed", true ); } Else { E. Row. Cells [5]. Text = StringFormat. HighLight ("reviewed", false ); } // Display unused words... E. Row. Cells [2]. Text = StringFormat. Out (e. Row. Cells [2]. Text, 18 ); } } |
The SelectedIndexChanging event occurs after you click the "Review/cancel" button of a row. This program uses this event to review and cancel the supply and demand information. The implementation code is as follows:
Routine 31 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
Protected void GridView1_SelectedIndexChanging (object sender, GridViewSelectEventArgs e) { String id = GridView1.DataKeys [e. NewSelectedIndex]. Value. ToString (); Operation. UpdateInfo (id, infoType ); // Bind data by audit type (three categories: Show All (-1), show unreviewed (0), show audit (1 )) Switch (CheckType) { Case-1: GridViewBind (infoType ); Break; Case 0: GridView1.DataSource = operation. SelectInfo (infoType, false ); GridView1.DataBind (); Break; Case 1: GridView1.DataSource = operation. SelectInfo (infoType, true ); GridView1.DataBind (); Break; } } |
The RowDeleting event occurs when you click the "details" button of a row, but before the GridView control deletes the row. You can use the DELETE command to view the detailed Supply and Demand Information. The implementation code is as follows:
Task 32 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string id = GridView1.DataKeys[e.RowIndex].Value.ToString(); Response.Write("<script> window.open('DetailInfo.aspx?id=" + id + "&&type=" + infoType + "','','height=258, width=679, top=200, left=200') </script>"); Response.Write("<script>history.go(-1)</script>"); } |
The PageIndexChanging event occurs when you click a page navigation button, but before the GridView control handles the paging operation. This event is mainly used to implement the page paging function. In addition, this program mainly implements the display of Supply and Demand Information Based on audit, non-audit, etc., you need to bind the GridView control according to the corresponding data source, otherwise the program will not report an error, however, pagination may occur. The implementation code is as follows:
Routine 33 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
Protected void GridView1_PageIndexChanging (object sender, GridViewPageEventArgs e) { // Pagination settings GridView1.PageIndex = e. NewPageIndex; // Bind data by audit type (three categories: Show All (-1), show unreviewed (0), show audit (1 )) Switch (CheckType) { Case-1: GridViewBind (infoType ); Break; Case 0: GridView1.DataSource = operation. SelectInfo (infoType, false ); GridView1.DataBind (); Break; Case 1: GridView1.DataSource = operation. SelectInfo (infoType, true ); GridView1.DataBind (); Break; } // Display the current page number LblPageSum. Text = "the current page is" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + "page "; } |
Click "reviewed Supply and Demand Information" to display the reviewed supply and demand information. The implementation code is as follows:
Routine 34 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
Protected void rdoBtnCheckTrue_CheckedChanged (object sender, EventArgs e) { GridView1.PageIndex = 0; GridView1.DataSource = operation. SelectInfo (infoType, true ); GridView1.DataBind (); CheckType = 1; // Display the current page number LblPageSum. Text = "the current page is" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + "page "; } |
Click "unaudited Supply and Demand Information" to display unaudited supply and demand information. The implementation code is as follows:
Sample 35 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
Protected void rdoBtnCheckFalse_CheckedChanged (object sender, EventArgs e) { GridView1.PageIndex = 0; GridView1.DataSource = operation. SelectInfo (infoType, false ); GridView1.DataBind (); CheckType = 0; // Display the current page number LblPageSum. Text = "Current page is" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + "page "; } |
Click "show all supply and demand information of the same type" to display all supply and demand information of the same type. The implementation code is as follows:
Sample 36 Code Location: CD \ TM \ 01 \ SIS \ BackGround \ CheckInfo. aspx. cs
Protected void rdoBtnCheckAll_CheckedChanged (object sender, EventArgs e) { GridView1.PageIndex = 0; GridViewBind (infoType ); CheckType =-1; // Display the current page number LblPageSum. Text = "the current page is" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + "page "; } |
[Responsible editor: xia shu TEL :( 010) 68476606]