2012-08-11 84 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(); 

}