2012-08-11 42 views
1

这是我的数据库记录编程方式来显示HTML报告

 First_Name Study_Desc    VISIT_DATE RATE 
     Sunita  Study Cy    2012-02-11 5000.00 
     Imran  Study Ey    2012-02-11 8000.00 
     gdf   Study Ud    2012-02-11 7000.00 
     shubham  Study Ey    2012-02-11 8000.00 
     shweta  Study Ey    2012-02-11 8000.00 

我必须表现出这样的HTML表格。我如何以编程方式显示报告Study_Desc明智的(或有任何数据库查询)。

Study ->(Study Cy) 
    FirstName Date  Rate 
    Sunita 2012-02-11 5000.00 

    Study ->(Study Ey) 
    FirstName Date  Rate 
    Imran 2012-02-11 8000.00 
    shubham 2012-02-11 8000.00 
    shweta 2012-02-11 8000.00 

    Study ->(Study Ud) 
    FirstName Date  Rate 
    gdf  2012-02-11 7000.00 


<table id="tableReport" runat="server"> 
</table> 

我如何编程显示报告

我都试过,但格式不正确

回答

1

,而不是直接写入到它是在一个StringBuilder对象最好先写流。

  1. 将网页
  2. 上的标签控制写你的HTML在StringBuilder对象
  3. 设置标签文本属性等于字符串生成器对象

例子:

aspx Code 
<asp:Label ID="lbReport" runat="server" /> 

// Code Behind 

public void PopulateOnPayment() 
{  
     StringBuilder sb = new StringBuilder(); 
     sb.Write("<table width='95%' border='1' cellpadding='0' cellspacing='0'    align='center'>"); 
     sb.Write("<tr>"); 
     sb.Write("<td>"); 
     ...... 
     ............ 
     .............. write your html and at the end set it equal to label text 

     lbReport.Text = sb.ToString(); 

}