asp.net中将DataTable根据xslt生成html静态页面,支持分页

功能很单一,也不是很完善~~,虚心听各位的教诲*^_^*
代码如下:
ContractedBlock.gif ExpandedBlockStart.gif
None.gifusing System;
None.gif
using System.Data;
None.gif
using System.Xml;
None.gif
using System.Text;
None.gif
using System.Xml.Xsl;
None.gif
using System.Xml.XPath;
None.gif
using System.IO;
None.gif
using System.ComponentModel;
None.gif
None.gif
namespace htmldemo
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 创建者:齐明||时间:2007-5-16||功能:生成静态页面
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class xmlhtml:IDisposable
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
public string strXmlName_;
InBlock.gif        
public string strHTMLName_;
InBlock.gif        
public string strXSLTName_;
InBlock.gif        
public int intPageSize_;
InBlock.gif        
public DataTable dts_;
InBlock.gif        
private int _intCx=0;
InBlock.gif        
private bool disposed = false;
InBlock.gif        
private Component component = new Component();
InBlock.gif        
private IntPtr handle;
InBlock.gif
InBlock.gif        
public xmlhtml()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public xmlhtml(DataTable dt,string XmlFileName,string HtmlFileName,string XsltFileName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            strXmlName_
=XmlFileName;
InBlock.gif            strHTMLName_
=HtmlFileName;
InBlock.gif            strXSLTName_
=XsltFileName;
InBlock.gif            dts_
=dt;
InBlock.gif            _intCx
=2;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public xmlhtml(DataTable dt,string XmlFileName,string HtmlFileName,string XsltFileName,int PageSize)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            strXmlName_
=XmlFileName;
InBlock.gif            strHTMLName_
=HtmlFileName;
InBlock.gif            strXSLTName_
=XsltFileName;
InBlock.gif            intPageSize_
=PageSize;
InBlock.gif            dts_
=dt;
InBlock.gif            _intCx
=1;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public xmlhtml(IntPtr handle)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.handle = handle;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public void Dispose()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Dispose(
true);
InBlock.gif            GC.SuppressFinalize(
this);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void Dispose(bool disposing)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
// Check to see if Dispose has already been called.
InBlock.gif
            if(!this.disposed)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
// If disposing equals true, dispose all managed 
InBlock.gif                
// and unmanaged resources.
InBlock.gif
                if(disposing)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
// Dispose managed resources.
InBlock.gif
                    component.Dispose();
ExpandedSubBlockEnd.gif                }

InBlock.gif             
InBlock.gif                
// Call the appropriate methods to clean up 
InBlock.gif                
// unmanaged resources here.
InBlock.gif                
// If disposing is false, 
InBlock.gif                
// only the following code is executed.
InBlock.gif
                CloseHandle(handle);
InBlock.gif                handle 
= IntPtr.Zero;            
ExpandedSubBlockEnd.gif            }

InBlock.gif            disposed 
= true;         
ExpandedSubBlockEnd.gif        }

InBlock.gif        [System.Runtime.InteropServices.DllImport(
"Kernel32")]
InBlock.gif        
private extern static Boolean CloseHandle(IntPtr handle);
InBlock.gif        
~xmlhtml()      
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
// Do not re-create Dispose clean-up code here.
InBlock.gif            
// Calling Dispose(false) is optimal in terms of
InBlock.gif            
// readability and maintainability.
InBlock.gif
            Dispose(false);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool StaticHtml()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(_intCx==0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else if(_intCx==1)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return StaticHtml(dts_,strXmlName_,strHTMLName_,strXSLTName_,intPageSize_);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else if(_intCx==2)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return StaticHtml(dts_,strXmlName_,strHTMLName_,strXSLTName_);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-16||功能:根据sql语句和xslt样式表生成静态html页面,分页控制
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="dt">生成xml的DataTable</param>
InBlock.gif        
/// <param name="strSql">数据表的sql语句</param>
InBlock.gif        
/// <param name="strXmlName">中间生成的xml的路径</param>
InBlock.gif        
/// <param name="strHTMLName">生成的静态html的路径</param>
InBlock.gif        
/// <param name="strXSLTName">样式表xslt的路径</param>
InBlock.gif        
/// <param name="pagesize">分页尺寸</param>
ExpandedSubBlockEnd.gif        
/// <returns>成功true</returns>

InBlock.gif        public bool StaticHtml(DataTable dt,string strXmlName,string strHTMLName,string strXSLTName,int pagesize)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(dt!=null && strXmlName!=null && strHTMLName!=null && strXSLTName!=null && strXmlName!="" && strHTMLName!="" && strHTMLName!="")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                processDirectory(strXmlName);
InBlock.gif                processDirectory(strHTMLName);
InBlock.gif                
//processDirectory(strXSLTName);
InBlock.gif
                int temp=TransformDTIntoXML(dt,strXmlName,pagesize);
InBlock.gif                
if(temp!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if(TransformXMLIntoHtml(strXmlName,strHTMLName,strXSLTName,temp)==true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
return true;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
return false;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return false;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-16||功能:根据sql语句和xslt样式表生成静态html页面
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="strSql">数据表的sql语句</param>
InBlock.gif        
/// <param name="strXmlName">中间生成的xml的路径</param>
InBlock.gif        
/// <param name="strHTMLName">生成的静态html的路径</param>
InBlock.gif        
/// <param name="strXSLTName">样式表xslt的路径</param>
ExpandedSubBlockEnd.gif        
/// <returns>成功true</returns>

InBlock.gif        public bool StaticHtml(DataTable dt,string strXmlName,string strHTMLName,string strXSLTName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(dt!=null && strXmlName!=null && strHTMLName!=null && strXSLTName!=null && strXmlName!="" && strHTMLName!="" && strHTMLName!="")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                processDirectory(strXmlName);
InBlock.gif                processDirectory(strHTMLName);
InBlock.gif                
//processDirectory(strXSLTName);
InBlock.gif
                if(TransformDTIntoXML(dt,strXmlName)==true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if(TransformXMLIntoHtml(strXmlName,strHTMLName,strXSLTName)==true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
return true;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
return false;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return false;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-16||功能:将xml转换成html
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="strHtmlName">要生成的html路径</param>
InBlock.gif        
/// <param name="strXMLName">要转换的xml路径</param>
InBlock.gif        
/// <param name="strXSLTName">样式表路径</param>
ExpandedSubBlockEnd.gif        
/// <returns>成功true</returns>

InBlock.gif        private bool TransformXMLIntoHtml(string strXMLName,string strHtmlName,string strXSLTName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string filename=strXMLName;
InBlock.gif                
string stylesheet=strXSLTName;
InBlock.gif                
string html=strHtmlName;
InBlock.gif                XslTransform xslt 
= new XslTransform();
InBlock.gif                xslt.Load(stylesheet);
InBlock.gif                XPathDocument xpathdocument 
= new XPathDocument(filename);
InBlock.gif                XmlTextWriter writer 
= new XmlTextWriter(html,Encoding.UTF8);
InBlock.gif                xslt.Transform(xpathdocument, 
null, writer, null);
InBlock.gif                writer.Close();
InBlock.gif                
return true;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                e
=null;
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-16||功能:将xml转换成html,支持分页
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="strHtmlName">要生成的html路径</param>
InBlock.gif        
/// <param name="strXMLName">要转换的xml路径</param>
InBlock.gif        
/// <param name="strXSLTName">样式表路径</param>
ExpandedSubBlockEnd.gif        
/// <returns>成功true</returns>

InBlock.gif        private bool TransformXMLIntoHtml(string strXMLName,string strHtmlName,string strXSLTName,int pagecount)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
for(int i=0;i<pagecount;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
string filename=processFileName(i,strXMLName);
InBlock.gif                    
string stylesheet=strXSLTName;
InBlock.gif                    
string html=processFileNameHtml(i,strHtmlName);
InBlock.gif                    XslTransform xslt 
= new XslTransform();
InBlock.gif                    xslt.Load(stylesheet);
InBlock.gif                    XPathDocument xpathdocument 
= new XPathDocument(filename);
InBlock.gif                    XmlTextWriter writer 
= new XmlTextWriter(html,Encoding.UTF8);
InBlock.gif                    xslt.Transform(xpathdocument, 
null, writer, null);
InBlock.gif                    writer.Close();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return true;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                e
=null;
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-16||功能:将DataTable转换成Xml文件,支持分页
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="dt">要转换的DataTable</param>
InBlock.gif        
/// <param name="strXMLName">生成xml的路径</param>
InBlock.gif        
/// <param name="intPageSize">分页页面尺寸</param>
ExpandedSubBlockEnd.gif        
/// <returns>成功true</returns>

InBlock.gif        private int TransformDTIntoXML(DataTable dt,string strXMLName,int intPageSize)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
int pno=dt.Rows.Count/intPageSize;
InBlock.gif                
if(dt.Rows.Count%intPageSize>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    pno
++;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
int countstart=0;
InBlock.gif                
int countend=dt.Rows.Count;
InBlock.gif                
int nowcount = dt.Rows.Count;
InBlock.gif                
for(int k=0;k<pno;k++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    XmlTextWriter xtw
=new XmlTextWriter(processFileName(k,strXMLName),null);
InBlock.gif                    
int page=k+1;
InBlock.gif                    
if(page * intPageSize<nowcount)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        countstart 
=(page-1* intPageSize;
InBlock.gif                        countend 
= page * intPageSize;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else if((page==1)&&(page * intPageSize>nowcount))
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        countstart 
=0;
InBlock.gif                        countend 
=nowcount;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        countstart 
= (page-1)*intPageSize;
InBlock.gif                        countend 
= nowcount;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    xtw.WriteStartDocument();
InBlock.gif                    xtw.WriteStartElement(
"records");
InBlock.gif                    
for(int i=countstart;i<countend;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        xtw.WriteStartElement(
"record");
InBlock.gif                        
for(int j=0;j<dt.Columns.Count;j++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            xtw.WriteStartElement(dt.Columns[j].ColumnName);
InBlock.gif                            xtw.WriteString(dt.Rows[i][j].ToString());
InBlock.gif                            xtw.WriteEndElement();
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        xtw.WriteEndElement();
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    xtw.WriteStartElement(
"pagecontrol");
InBlock.gif                    xtw.WriteStartElement(
"recordcount");
InBlock.gif                    xtw.WriteString(Convert.ToString(nowcount));
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteStartElement(
"firstpage");
InBlock.gif                    xtw.WriteString(strXMLName.Replace(
".xml",".html"));
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteStartElement(
"previouspage");
InBlock.gif                    xtw.WriteString(previousFileName(k,strXMLName));
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteStartElement(
"nextpage");
InBlock.gif                    xtw.WriteString(nextFileName(k,strXMLName,pno));
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteStartElement(
"lastpage");
InBlock.gif                    xtw.WriteString(processFileNameHtml(pno
-1,strXMLName.Replace(".xml",".html")));
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteStartElement(
"nowpage");
InBlock.gif                    xtw.WriteString(Convert.ToString(k
+1));
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteStartElement(
"current");
InBlock.gif                    xtw.WriteString(processFileNameHtml(k,strXMLName.Replace(
".xml",".html")));
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.WriteEndElement();
InBlock.gif                    xtw.Close();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return pno;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                e
=null;
InBlock.gif                
return -1;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-16||功能:将DataTable转换成Xml文件
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="dt">要转换的DataTable</param>
InBlock.gif        
/// <param name="strXMLName">生成xml的路径</param>
ExpandedSubBlockEnd.gif        
/// <returns>成功true</returns>

InBlock.gif        private bool TransformDTIntoXML(DataTable dt,string strXMLName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                XmlTextWriter xtw
=new XmlTextWriter(strXMLName,null);
InBlock.gif                xtw.WriteStartDocument();
InBlock.gif                xtw.WriteStartElement(
"records");
InBlock.gif                
for(int i=0;i<dt.Rows.Count;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    xtw.WriteStartElement(
"record");
InBlock.gif                    
for(int j=0;j<dt.Columns.Count;j++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        xtw.WriteStartElement(dt.Columns[j].ColumnName);
InBlock.gif                        xtw.WriteString(dt.Rows[i][j].ToString());
InBlock.gif                        xtw.WriteEndElement();
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    xtw.WriteEndElement();
ExpandedSubBlockEnd.gif                }

InBlock.gif                xtw.WriteEndElement();
InBlock.gif                xtw.Close();
InBlock.gif                
return true;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                e
=null;
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-16||功能:处理文件的路径,如果目录不存在,则建立目录
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="filename">需要处理的文件路径</param>

InBlock.gif        private void processDirectory(string filename)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(Directory.Exists(getpath(filename))==false)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Directory.CreateDirectory(getpath(filename));
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string getpath(string filename)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(filename!=null && filename !="")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return filename.Substring(0,filename.LastIndexOf("\\"));
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return "";
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 创建者:齐明||时间:2007-5-17||功能:处理分页文件名
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="pagenumber"></param>
InBlock.gif        
/// <param name="filename"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        private string processFileName(int pagenumber,string filename)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(pagenumber==0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return filename;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string strTemp=filename.Replace(".xml","_"+Convert.ToString(pagenumber)+".xml");
InBlock.gif                
return strTemp;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string processFileNameHtml(int pagenumber,string filename)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(pagenumber==0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return filename;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string strTemp=filename.Replace(".html","_"+Convert.ToString(pagenumber)+".html");
InBlock.gif                
return strTemp;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string previousFileName(int pagenumber,string filename)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            pagenumber
--;
InBlock.gif            
if(pagenumber==0 || pagenumber<0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return filename.Replace(".xml",".html");
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string strTemp=filename.Replace(".xml","_"+Convert.ToString(pagenumber)+".html");
InBlock.gif                
return strTemp;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string nextFileName(int pagenumber,string filename,int pagecount)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            pagenumber
++;
InBlock.gif            
if(pagenumber<pagecount)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string strTemp=filename.Replace(".xml","_"+Convert.ToString(pagenumber)+".html");
InBlock.gif                
return strTemp;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return filename.Replace(".xml","_"+Convert.ToString(pagenumber-1)+".html");
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

有两种使用方法。
第一种:实例化时初始化数据,例:
None.gif          private   void  Page_Load( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
// 在此处放置用户代码以初始化页面
InBlock.gif
            string strSql="Select c.CRM_ID,c.crm_cn,c.CRM_TYPE_ID login_name From crm c Where c.status='0'";
InBlock.gif            OracleDb conn
=new OracleDb();
InBlock.gif            DataTable dt
=new DataTable();
InBlock.gif            dt
=conn.GetDtRecorder(strSql);
InBlock.gif            
string strAPath=Request.PhysicalApplicationPath;
InBlock.gif            
string strXmlname=strAPath+"xsltdemo\\crm.xml";
InBlock.gif            
string strHtmlname=strAPath+"xsltdemo\\crm.html";
InBlock.gif            
string strXSLTname=strAPath+"xsltdemo\\crm.xslt";
InBlock.gif            xmlhtml sh
=new xmlhtml(dt,strXmlname,strHtmlname,strXSLTname,100);
InBlock.gif            sh.StaticHtml();
InBlock.gif            sh.Dispose();
ExpandedBlockEnd.gif        }
代码
xmlhtml sh=new xmlhtml(dt,strXmlname,strHtmlname,strXSLTname,100)
dt是提供数据源的datatable,strXmlname是中间生成的xml文件的路径,strHtmlname是生成的静态html页面路径,strXSLTname是xslt样式表的路径,100是分页后每页代码显示的记录行数。
注:最后的页面尺寸参数可以不加,默认整个数据表显示到一个页面。

第二种:实例化后直接使用StaticHtml方法。最后三行为
None.gif             xmlhtml sh = new  xmlhtml();
None.gif            sh.StaticHtml(dt,strXmlname,strHtmlname,strXSLTname,
100 );
None.gif            sh.Dispose();

demo下载

转载于:https://www.cnblogs.com/suntears/archive/2007/05/17/750209.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值