Author: Unknown author please contact me speed
Entries
IT
There have been a few years in the industry.
,
Previously
PB6.0
Now
.NET
technology
,
Computer technology has huge progress from hardware or software
.
The overall level of Chinese programmers is also far behind in the world, which lacks perfect system, the necessary exchanges and programmers' ideas of personal heroism is the main reason.
.
Not long ago, I met with it.
DataGrid
Classification Display data problem, displayed in the following figure
:
I hope to provide a solution for friends who meet similar problems.
,
And master similar problems
.
Analysis of the problem:
For example, each course is different categories, you need to summarize the first category of display data. It is difficult to achieve the above features with standard DataGrid. Obviously, it is obvious to solve itself.
Idea:
In the final analysis, no matter what style of the form is displayed, it is manifested to the front desk is a Table element of HTML, so if you can dynamically determine the HTML style when reading data, the HTML is generated to the front desk, and can be controlled by the DIV. Display. This is actually included in the process of pushing from the existing HTML to dynamic HTML generation.
Source code and annotation:
Define class saving category names and data
public class KeyVal {private string m_Skey; private string m_SVal; public string strKey {get {return m_Skey;} set {m_Skey = value;}} public string strVal {get {return m_SVal;} set {m_SVal = value;}} public KeyVal ()} Public keyval (string skey, string sval) {strkey = SKEY; STRVAL = sval;}}}
Test page code and related functions
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls Using system.web.ui.htmlcontrols; using system.security.principal; using microsoft.Web.ui.webcontrols; using system.text;
Namespace EisWebsite.Webinternet {///
#ndregion
#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///
Private string createuntml () {
// Take the number of types and name Dataset dset = new dataset (); DSET = Add your own acquisition data set function (flexible design SQL statement) result is type, number
//Appglobal.appsyswebservice.classcourseteteachermainfilters (ITEM);
ArrayList (); foreach (DATAROW DROW IN DSET.TABLES [0] .ROWS) {keyval mobj = new keyval (); mobj.strkey = drow [0] .tostring (); mobj.strval = drow [ 1] .tostring (); mlist.add (mobj);} StringBuilder outhtml = new stringbuilder (); dset = Add your own data set function. Note that the data is sorted and the same
//AppGlobal.AppSysWebService.ClassCourseTeacherFilters(Item); // add a fixed header OutHtml.Append ( "