Subhash Sharma

Subhash Sharma
Subhash Sharma

This is Subhash Sharma(Software Engineer) Blog

Welcome to this blog and find every solution.............

Search This Blog

Software Engineer(Subhash Sharma)

Software Engineer(Subhash Sharma)
Software Engineer

Tuesday, February 22, 2011

HTML Report in c# .Net

//Blog does not take starting tag of the html.....please write all starting tag and end tag before each table tag,th tag and tr tag and td tag and closing tag...


protected void btnHtmlkReport_Click(object sender, EventArgs e)
{
conn.open();
SqlCommand cmd = new SqlCommand("select * from students", conn);
SqlDataReader oDr = cmd.ExecuteReader();
if (oDr.HasRows)
{
StringBuilder sb = new StringBuilder();
sb.Append("table align='center'>");
sb.Append("tr> td > th>Financial Report /th>/td>/tr>");
sb.Append("tr>td align='center'>");
sb.Append("id".ToString());
sb.Append("/td>");
sb.Append("td align='center'>");
sb.Append("Name".ToString());
sb.Append("/td>");
sb.Append("td align='center'>");
sb.Append("Roll".ToString());
// finish the rest of the row
sb.Append("");
// get your data
while (oDr.Read())
{
sb.Append("tr>td align='center'>");
sb.Append(oDr["id"].ToString());
sb.Append("/td>");
sb.Append("td align='center'>");
sb.Append(oDr["Name"].ToString());
sb.Append("/td>");
sb.Append("td align='center'>");
sb.Append(oDr["Roll"].ToString());
// finish the rest of the row
sb.Append("/td>/tr>");
}
sb.Append("/table>");
Response.Write(sb);
con.close();
}
}

No comments:

Post a Comment