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

Wednesday, February 23, 2011

HTML REPORT and Print the Html Report

//Take one Input Button for Print

input type="button" id="btnPrint" runat="server" value ="Print" onclick ="PrintReport();"/>

//Make one method for print

script type="text/javascript" language="javascript" >
function PrintReport() {
var bt = document.getElementById("btnPrint").style.display='block';
window.print()

}
/script>

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

}



}

No comments:

Post a Comment