lax
lax

Reputation: 518

Programmatically to show HTML report

This is my database record

        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

I have to show like this in html table. How do I programmatically to show report Study_Desc wise (or is there any database query).

   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>

How do I programmatically to show report

I have tried this but not in proper format

Upvotes: 1

Views: 1157

Answers (1)

Waqar Janjua
Waqar Janjua

Reputation: 6123

Instead of directly writing to the stream it is better to first write in a stringbuilder object.

  1. Place a label control on your page
  2. Write your html in a stringbuilder object
  3. Set the label text property equal to string builder object

Example:

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();

 }

Upvotes: 1

Related Questions