Hi
I have a drop down list which has 5 options earrings, necklace,bangles,rings, bracelets
and beside that i have two buttons. 1 show button and 1 print button.
on clicking any of the options from drop down list, then clicking on show,the gridview data shows of that particular type.
e.g
sl.no category cost price sold price
2 earrings 200 400
3 earrings 5000 3000
7 earrings 7000 2000
now i want clicking on print button, these data to be showed in crystal report and print directly from there.
how to do so?
i have created dataset also.
i will attach the code also.
private DataSet GetAllJewellery()
{
using (SqlConnection con = new SqlConnection(JewelleryHelper.GetConnectionString()))
{
using (SqlCommand cmd = new SqlCommand("spGetJeweleryOnSoldItems", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Category", SqlDbType.VarChar).Value = ddlCategory.SelectedItem.Text;
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
con.Close();
return ds;
}
}
}
protected void btnPrint_Click(object sender, EventArgs e)
{
SoldItemsDataSetTableAdapters.spGetJeweleryOnSoldItemsTableAdapter getAllJewellerySoldItems = new SoldItemsDataSetTableAdapters.spGetJeweleryOnSoldItemsTableAdapter();
DataTable dt = getAllJewellerySoldItems.GetAllJewellerySoldItems(this.ddlCategory.SelectedValue);
ReportDocument rDoc = new ReportDocument();
rDoc.Load(Server.MapPath("soldCrystalReport.rpt"));
rDoc.SetDataSource(dt);
rDoc.SetParameterValue("Category", this.ddlCategory.SelectedValue);
this.crystalReportViewer.ReportSource = rDoc;
this.crystalReportViewer.DataBind();
this.crystalReportViewer.Focus();
}
}
but its not coming.
can anyone please help me.
Thanks
as i am stuck in here for the last 4 days.