Useful in many cases
For example, if you want to send an email to someone else, the content in this email can only be written in HTML. If it involves data display, it will be very convenient to use it.
Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
/** // <Summary>
/// The Z value is defined by yourself, which indicates the number of fields in your able. You can use table. Columns. Count to replace it, so that the total number of fields in the datatable can be automatically obtained.
/// </Summary>
Public class tohtml
{
Public String newhtml (datatable table, int Z)
{
Int hang = table. Rows. count;
String A = "<HTML> ABC ";
A + = "<Table> ";
For (INT I = 0; I {
A + = "<tr> ";
For (Int J = 0; j <z; j ++)
{
A + = "<TD> ";
A + = table. Rows [I] [J];
A + = "</TD> ";
}
A + = "</tr> ";
}
A + = "</table> ";
A + = "Return;
}
}
Hope to help you
Code for impermanence improvement: Public String newhtml (datatable table)
{
Int colcount = table. Columns. count;
Stringbuilder sb = new stringbuilder (1024*5 );
SB. append ("");
For (INT I = 0, rowcount = table. Rows. Count; I <rowcount; I ++)
{
SB. append ("");
Datarow ROW = table. Rows [I];
For (Int J = 0; j <colcount; j ++)
{
SB. append ("");
SB. append (row [J] = NULL? "": Row [J]. tostring ());
SB. append ("");
}
SB. append ("
");
}
SB. append ("");
Return sb. tostring ();
}
This class can also be better written, such as defining the field output (You may only need to output several fields instead of all fields)
The content is relatively simple and should be changed