Hi I had a gridview page which it contains the users id,fname,lname and five more things. Secondly i had created a view button in each row to redirect to another page called detail page, to view the details of the particular user. Thirdly my requirement is i need one more button called print button so that the detail items to print as pdf with logo, footer, header to be inside the pdf page. I watch the link https://www.aspsnippets.com/Articles/Create-PDF-Report-from-database-in-ASPNet-using-C-and-VBNet.aspx
its covering my thoughts but not i exactly want, (I am new for the asp.net) and my code
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!this.IsPostBack)
- {
- BindGridView();
- }
- }
- private void BindGridView()
- {
- string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
- SqlConnection con = new SqlConnection(constr);
- SqlCommand cmd = new SqlCommand("select * from details", con);
- DataTable dt = new DataTable();
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- da.Fill(dt);
- GridView1.DataSource = dt;
- GridView1.DataBind();
- }
- protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- if (e.CommandName == "EditButton")
- {
- int index = Convert.ToInt32(e.CommandArgument);
- GridViewRow row = GridView1.Rows[index];
- Response.Redirect("~/SD/EditView.aspx?EmpNo=" + row.Cells[0].Text);
- }
- if (e.CommandName == "PrintButton")
- {
- int index = Convert.ToInt32(e.CommandArgument);
- GridViewRow row = GridView1.Rows[index];
- }
- }
need help.
Thanks.