| |

VerySource

 Forgot password?
 Register
Search
View: 851|Reply: 9

Bind the data, and then display the content in the table in the format you want to display

[Copy link]

3

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-14 16:00:01
| Show all posts |Read mode
-------------------------------------------------- ------------------------
Lessons | Lessons | Courses | Course Name | Hours Allocation | Hours Arrangement |
| Cheng | 程 | Number | | -------------- | -------------------------- | Points |
| Sex | Class | | | Lectures | Experiments | Computer | First academic year | Second academic year | Third academic year |
| Quality | Don't | | | | -------------------------- | |
| ------ | ------ | ------------ | -------------- | One | Two | One | Two | One | two | --- |
| Required | Public | 111000 | Marx's Principle | 48 | 48 | 0 | 3 | | | | | | |
| | Total | 111001 | ******* | 25 | 25 | 0 | | 3 | | | | | |
| Course | | | | | | | | | | | | | |
| | ------------------------------------------------ ---------------- | |
| | Subtotal | 73 | 73 | 0 | 3 | 3 | | | | |
| | ------------------------------------------------ ---------------- | --- |
| | Select | 111000 | Marx's Principles | 48 | 48 | 0 | 3 | | | | | | |
| | 修 | 111001 | ******* | 25 | 25 | 0 | | 3 | | | | | |
| | Lesson | | | | | | | | | |
| |-| ------ | ------------ | -------------- | ---------- ---------------- | |
| Subtotal | 73 | 73 | 0 | 3 | 3 | | | | |
| --- | --------------------------------------------- -----------------------
I want to display the data I got from the database in this way. This is just a Liezi, and there are many subjects of the same level in public courses. How is this way implemented in Asp.Net
Reply

Use magic Report

0

Threads

23

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-4-30 21:30:01
| Show all posts
Organize a DataTable by yourself
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-5-1 10:15:01
| Show all posts
I rely on it. This table is difficult. Do n’t use the built-in controls such as Repeater and DataGrid. It is estimated that it is difficult to get it out. Write a table in the background and bind the DataSet data. Then output this HTML to the foreground .
Reply

Use magic Report

0

Threads

26

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-5-1 18:00:01
| Show all posts
If your form is implemented with DataGrid (vs2003) or GridView (vs2005), it may be more difficult.
I suggest you write a table in html. The premise of using this method is that this table basically does not need to be operated, just displayed.
You need to define a public variable in cs, and then negative value for this variable in cs:
public string StrTab = null;
Write in the Page_Load event:
StrTab = "<table>" +
            "<tr>" +
                "<td> Column 1 </ td>" +
                "<td> Column 2 </ td>" +
            "</ tr>" +
        "</ table>";
Then you put this variable in the HTML code:
<form id = "form1" runat = "server">
<% = StrTab%>
</ form>
This can be achieved. As for the internal format of this table, you need to make a logical judgment and combine it (this is not difficult).
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-5-1 22:30:01
| Show all posts
Ha ha. This is not difficult.
If the form is dead. Then draw the table first, and use Label to bind the data.
If it is dynamic, it depends on how the database is designed. But in principle, spell it out with ASP: TABLE, you need to know from the data that each box needs to span several rows and columns.
The general meaning is as follows:
dim tr as TableRow
dim tc as TableCell

for loop
   tr = new TableRow
   for loop
      tc = new TableCell
      tc.text = Data required
      tc.RowSpan = Row span number
      tc.ColSpan = column span
      tr.Cells.add (tc)
   next
   Table1.Rows.add (tr)
next

You have to think about the details. Anyway, it took me three days to spell out a large report, involving eight database tables, using a four-layer For loop. I guess you will be a lot simpler.
Reply

Use magic Report

0

Threads

14

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-5-2 09:00:02
| Show all posts
Consider using Xml and Xsl: Use the style sheet Xsl to form the above title and content based on the column names and data in special rows (such as subtotals)
Reply

Use magic Report

0

Threads

14

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-5-2 19:45:01
| Show all posts
Simple example:
xml file format:
<? xml version = "1.0" encoding = "utf-8"?>
<!-This Xml file is a template file in Xml format corresponding to the query result record of the department's monthly fund plan report->
<MonthBankRollPlanOfDepartReport>
<SchemaInfo> <!-Style->
<Columns> <!-Column->
<Titles class = "dgdTitle" height = "20px" align = "center">
<!-Title details: Style: style; IsFixed: whether it is fixed; TitleName: title name->
<TitleDetail width = "270" IsFixed = "true" TitleName = "Cost category">
<!-Column details: ColumnName: column name; Style: style; IsUnit: merge when the same data in the column; align: position of text->
<ColumnDetail ColumnName = "TopSysExpenseItemName" width = "120" IsUnit = "true" align = "center" />
<ColumnDetail ColumnName = "SysExpenseItemName" width = "150" align = "center" />
</ TitleDetail>
<TitleDetail width = "150" IsFixed = "true" TitleName = "小 计">
<ColumnDetail ColumnName = "Total" width = "150" align = "right" />
</ TitleDetail>
<!-Default title->
<DefaultTitle width = "150">
<ColumnDetail width = "150" align = "right" />
</ DefaultTitle>
</ Titles>
</ Columns>
<Rows>
<!-The color of some rows: ColumnName: Judgment column->
<RowColors ColumnName = "SysExpenseItemName">
<RowDetail ColumnValue = "Development cost subtotal" bgcolor = "# aee6ff" />
<RowDetail ColumnValue = "Period Expense Subtotal" bgcolor = "# aee6ff" />
<RowDetail ColumnValue = "Subtotal of other expenses" bgcolor = "# aee6ff" />
<RowDetail ColumnValue = "Cash Outflow Subtotal" bgcolor = "# aee6ff" />
<RowDetail ColumnValue = "Cash Inflow Subtotal" bgcolor = "# aee6ff" />
</ RowColors>
<!-The number of occupied columns of some rows: ColumnName: Judgment column->
<ColumnUnit ColumnName = "SysExpenseItemName" colspan = "2">
<RowDetail ColumnValue = "Subtotal Cash Outflow" />
<RowDetail ColumnValue = "Cash Inflow Subtotal" />
<RowDetail ColumnValue = "Net Cash Flow" />
</ ColumnUnit>
<RowLinks>
<RowDetail ColumnValue = "Development Cost" LinkType = "1" ColumnName = "TopSysExpenseItemName" />
<RowDetail ColumnValue = "Sales Expense" LinkType = "1" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "Project Promotion Cost" LinkType = "1" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "Administrative Expenses" LinkType = "1" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "Development overhead" LinkType = "1" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "Financial Expenses" LinkType = "1" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "Tax" LinkType = "1" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "Shareholder Dividend" LinkType = "1" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "This month's acceptance payment" LinkType = "2" ColumnName = "SysExpenseItemName" />
<RowDetail ColumnValue = "New acceptance this month" LinkType = "2" ColumnName = "SysExpenseItemName" />
</ RowLinks>
</ Rows>
</ SchemaInfo>
<Data> <!-Data->
<ColumnInfo>
<ColumnDetail ColumnName = "***" />
</ ColumnInfo>
<DataInfo>
<!-Data format->
<DataDetail>
<FieldDetail Name = "***" Value = "" />
<FieldDetail Name = "***" Value = "" />
</ DataDetail>
<DataDetail>
<FieldDetail Name = "***" Value = "" />
<FieldDetail Name = "***" Value = "" />
</ DataDetail>
</ DataInfo>
</ Data>
</ MonthBankRollPlanOfDepartReport>
Reply

Use magic Report

0

Threads

14

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-5-2 22:15:01
| Show all posts
Xsl test:
<? xml version = "1.0" encoding = "UTF-8"?>
<xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform">
<!-Global Variables->
<xsl: variable name = "Columns" select = "/ MonthBankRollPlanOfDepartReport / SchemaInfo / Columns" /> <!-Column format->
<xsl: variable name = "Rows" select = "/ MonthBankRollPlanOfDepartReport / SchemaInfo / Rows" /> <!-row format->
<xsl: variable name = "ColumnInfo" select = "/ MonthBankRollPlanOfDepartReport / Data / ColumnInfo" /> <!-Data column information->
<xsl: variable name = "DataInfo" select = "/ MonthBankRollPlanOfDepartReport / Data / DataInfo" /> <!-Data Information->
<xsl: variable name = "ShowMonthColumn" select = "/ MonthBankRollPlanOfDepartReport / Data / ColumnInfo / ColumnDetail [starts-with (@ColumnName, 'A')]" /> <!-Show the month's column->
<xsl: variable name = "UnitColumnName" select = "/ MonthBankRollPlanOfDepartReport / SchemaInfo / Columns / Titles / TitleDetail / ColumnDetail [@IsUnit = 'true'] / @ ColumnName" /> <!-Merge column name->
<xsl: variable name = "RowColorColumnName" select = "$ Rows / RowColors / @ ColumnName" /> <!-row color column name->

<!-Template->
<!-Get the month column heading->
<xsl: template name = "GetMonthTitle">
<xsl: param name = "TitleIndex" /> <!-Title Index->
<xsl: variable name = "ColumnName" select = "$ ShowMonthColumn [$ TitleIndex] / @ ColumnName" />
<xsl: value-of select = "substring ($ ColumnName, 2, 4)" /> <xsl: value-of select = "'year'" /> <xsl: value-of select = "substring ($ ColumnName, 6) "/> <xsl: value-of select =" '月' "/>
</ xsl: template>

<!-Get the title->
<xsl: template name = "GetTitle">
<tr align = "center">
<!-Specify the format title->
<xsl: for-each select = "$ Columns / Titles / TitleDetail">
<td width = "{./@width}px">
<xsl: choose>
<xsl: when test = "./@IsFixed = 'true'">
<xsl: attribute name = "style">
<xsl: value-of select = "'background-color: # BED8FD; border-right: 1px solid #cccccc; border-top: 1px solid #cccccc; position: relative; left: expression (this.parentElement.parentElement.parentElement .parentElement.parentElement.parentElement.parentElement.parentElement.scrollLeft) '"/>
</ xsl: attribute>
</ xsl: when>
<xsl: otherwise>
<xsl: attribute name = "style">
<xsl: value-of select = "'border-right: 1px solid #cccccc; border-top: 1px solid #cccccc;'" />
</ xsl: attribute>
</ xsl: otherwise>
</ xsl: choose>
The
<!-Title name->
<xsl: value-of select = "./@TitleName" />
</ td>
</ xsl: for-each>
<!-Month Title->
<xsl: for-each select = "$ ShowMonthColumn">
<td width = "{$ Columns / Titles / DefaultTitle / @ width} px" style = "border-right: 1px solid #cccccc; border-top: 1px solid #cccccc;">
<xsl: call-template name = "GetMonthTitle">
<xsl: with-param name = "TitleIndex" select = "position ()" />
</ xsl: call-template>
</ td>
</ xsl: for-each>
</ tr>
</ xsl: template>

<!-Get the column name of the navigation->
<xsl: template name = "GetRowLinksColumnName">
<xsl: param name = "DataDetail" /> <!-Details of the line->
<xsl: for-each select = "$ Rows / RowLinks / RowDetail">
<xsl: variable name = "RowDetail" select = "." />
<xsl: if test = "$ DataDetail / FieldDetail [@Name = $ RowDetail / @ ColumnName] / @ Value = $ RowDetail / @ ColumnValue">
<xsl: value-of select = "$ RowDetail / @ ColumnName" />
</ xsl: if>
</ xsl: for-each>
</ xsl: template>

<!-Get the displayed data->
<xsl: template name = "GetShowValue">
<xsl: param name = "ColumnName" />
<xsl: param name = "ShowValue" />
<xsl: param name = "Position" />
The
<xsl: variable name = "DataDetail" select = "$ DataInfo / DataDetail [$ Position]" />
The
<xsl: variable name = "RowLinksColumnName"> <!-Navigation column name->
<xsl: call-template name = "GetRowLinksColumnName">
<xsl: with-param name = "DataDetail" select = "$ DataDetail" />
</ xsl: call-template>
</ xsl: variable>
<xsl: variable name = "RowLinksValue" select = "$ DataDetail / FieldDetail [@Name = $ RowLinksColumnName] / @ Value" />
<!-Get the hyperlink type->
<xsl: variable name = "LinkType">
<xsl: choose>
<xsl: when test = "count ($ Rows / RowLinks / RowDetail [@ColumnValue = $ RowLinksValue])> 0 and not (contains ($ DataDetail / FieldDetail [@Name = 'SysExpenseItemName'] / @ Value, 'Subtotal' )) ">
<xsl: value-of select = "$ Rows / RowLinks / RowDetail [@ColumnValue = $ RowLinksValue] / @ LinkType" />
</ xsl: when>
<xsl: otherwise>
<xsl: value-of select = "-1" />
</ xsl: otherwise>
</ xsl: choose>
</ xsl: variable>
<xsl: choose>
<xsl: when test = "number ($ ShowValue)"> <!-number->
<xsl: choose>
<xsl: when test = "$ ColumnName = 'Total'">
<xsl: value-of select = "format-number ($ ShowValue, '#, ###. 00')" />
</ xsl: when>
<xsl: otherwise>
<xsl: choose>
<xsl: when test = "number ($ ShowValue)! = 0">
<xsl: choose>
<xsl: when test = "$ LinkType! = -1">
<a href = "#" onclick = "GetDataList ('{$ DataDetail / FieldDetail [@Name =' CompanyID '] / @ Value}', '{$ DataDetail / FieldDetail [@Name =' SysExpenseItemID '] / @ Value} ',' {$ ColumnName} ',' {$ DataDetail / FieldDetail [@Name = 'DepartIDs'] / @ Value}', '{$ LinkType}'); ">
<xsl: value-of select = "format-number ($ ShowValue, '#, ###. 00')" />
</a>
</ xsl: when>
<xsl: otherwise>
<xsl: value-of select = "format-number ($ ShowValue, '#, ###. 00')" />
</ xsl: otherwise>
</ xsl: choose>
</ xsl: when>
<xsl: otherwise>
<xsl: value-of select = "format-number ($ ShowValue, '#, ###. 00')" />
</ xsl: otherwise>
</ xsl: choose>
</ xsl: otherwise>
</ xsl: choose>
</ xsl: when>
<xsl: otherwise>
<xsl: choose>
<xsl: when test = "$ LinkType = 1 and $ ShowValue! = '0'"> <!-The cost of navigation->
<a href = "#" onclick = "GetSysExpenseItemList ('{$ DataDetail / FieldDetail [@Name =' CompanyID '] / @ Value}', '{$ DataDetail / FieldDetail [@Name =' SysExpenseItemID '] / @ Value} ',' {$ DataDetail / FieldDetail [@Name = 'DepartIDs'] / @ Value}'); ">
<xsl: value-of select = "$ ShowValue" />
</a>
</ xsl: when>
<xsl: otherwise>
<xsl: value-of select = "$ ShowValue" />
</ xsl: otherwise>
</ xsl: choose>
</ xsl: otherwise>
</ xsl: choose>
</ xsl: template>
Reply

Use magic Report

0

Threads

32

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-5-5 09:00:02
| Show all posts
Um, xml + xslt is a good way. It applies to the case where the format is unchanged and only the data is changed.
Reply

Use magic Report

0

Threads

58

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-5-10 22:45:01
| Show all posts
Use xml + xslt
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list