abdul imran

abdul imran

  • NA
  • 76
  • 1.7k

how to add row dynamically in html?

Feb 11 2015 12:09 AM
i have data in database table and i am fetching data in windows service and i have added html template to display database table data in html template in tabular format but in my html table can only display single row in table but i want ti display multiple row in html table so please help me to do this .
windows service code:




EmailDT = rsEmailDet.Tables[0];
            if (EmailDT.Rows.Count > 0)
            {


                EmailRow = EmailDT.Select();
                string Path = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
               
 
                ReqHTML = WClinet.DownloadString(Path + TemplateFileName.ToString());
               
                foreach (DataRow DtERow in EmailDT.Rows)
                {
                    TokenFied = DtERow["TokenFields"].ToString();
                    TokemVal = DtERow["TokenValue"].ToString();
                    if (TokenFied == "" || TokemVal == "")
                    {


                    }
               
                    else
                    {
                        if (NewHTML == "")
                        {
                            NewHTML = ReqHTML.Replace(TokenFied, TokemVal);
                        }
                        NewHTML = NewHTML.Replace(TokenFied, TokemVal);


                    }




                }


               
            }
               return NewHTML;
}






HTML CODE:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Employee Day Attendance Status</title>
    <style type="text/css">
        body { margin: auto; width: 700px;}
        p {margin-left:20px;margin-right:10px;text-align:justify;}
        a {color:#d52609;text-decoration:none;}
a:hover{color:#d52609;text-decoration:underline;}
li { 
   text-decoration: none;
   line-height:18px;
   padding:0px 0px 0px 10px;
   }
        .style1
        {
            width: 178px;
        }
        .style2
        {
            width: 151px;
        }
        .style3
        {
            width: 223px;
        }
        .style4
        {
            width: 167px;
        }
        .style5
        {
            width: 214px;
        }
        .style6
        {
            width: 229px;
        }
        .style7
        {
            width: 288px;
        }
    </style>
</head>
<body>


    <p>
       Dear <b><a>[NAME]</a></b> ,</p>
       <p>
           Attendance Details of the date  <b><a>[ATTENDANCEDATE]</a></b>  are as follows,</p>
       
           <table style="width: 66%;" border="1">
               <tr align="center">
                   <td class="style1">
                       Session I In</td>
                   <td class="style2">
                       Session I Out</td>
                   <td class="style3">
                       Session I Status</td>
                   <td class="style3">
                       Session II In</td>
                   <td class="style4">
                       Session II Out</td>
                   <td>
                       Session II Status</td>
               </tr>
               <tr align="center">
                   <td class="style1">
                       <b><a>[SESSIONIIN]</a></b></td>
                   <td class="style2">
                       <b><a>[SESSIONIOUT]</a></b></td>
                   <td class="style3">
                       <b><a>[SESSIONISTAUS]</a></b></td>
                   <td class="style3">
                       <b><a>[SESSIONIIIN]</a></b></td>
                   <td class="style4">
                       <b><a>[SESSIONIIOUT]</a></b></td>
                   <td>
                       <b><a>[SESSIONIISTATUS]</a></b></td>
               </tr>
           </table>
       


    <p>
        Sessions Late or Early Going Details :</p>
    <p>
        <table style="width: 62%;">
            <tr>
                <td class="style5">
                    Session I Late</td>
                <td class="style6">
                    Session I Early</td>
                <td class="style7">
                    Session II Late</td>
                <td>
                    Session II Early</td>
            </tr>
            <tr>
                <td class="style5">
                    <b><a>[SESSIONILATE]</a></b></td>
                <td class="style6">
                    <b><a>[SESSIONIEARLY]</a></b></td>
                <td class="style7">
                    <b><a>[SESSIONIILATE]</a></b></td>
                <td>
                    <b><a>[SESSIONIIEARLY]</a></b></td>
            </tr>
            <tr>
                <td class="style5">
                    &nbsp;</td>
                <td class="style6">
                    &nbsp;</td>
                <td class="style7">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
    </p>
       


</body>
</html>







Answers (3)