samedi 29 novembre 2014

How to add datasources to RDLC report in visual studio 2010 and pass values to textboxes in that Report


Vote count:

0




I am using Visual studio 2010 and i have added a rdlc report to the project. I am not using report wizard and instead i have created an empty rdlc report and i have added some textboxes to it. Using report data which is present below the toolbox i have created a dataset and added my table to it and when i open the expression window of the textbox and clicking the datasets i could see my table added to it as Dataset1 but when i click the fields category it says "Report item not linked to dataset". When i used visual studio 2008 i can easily add the dataset to report by just going to the menu bar and then into datasources and i choose the dataset and clicked the button that says "add to report". But i don't know how to do this vs 2010. Also try to post me the code for my situation which i am explaining below.


I have 4 textboxes directly placed in rdlc report by just dragging the textbox control from the toolbox and i have kept the names of those textboxes as Catalog No,Product Name,Date and Qty. I have a table which consists of all the above values in it and i need to display the values in those corresponding textboxes based on the catalog no which i specify in query using sqldataadapter. The code i used to do this is given below as follows.



protected void Page_Load(object sender, EventArgs e)
{
if(!Ispostback)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ERPConnectionString"].ConnectionString); LocalReport lr = null;
BLADE_ERPDataSet ds = new BLADE_ERPDataSet();
con.Open();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter("Select CatalogNo as CatalogNo, Productname as ProductName, Allotted_Qty as AllottedQty, CONVERT(VARCHAR(10),Allotted_Date,105) as AllottedDate from Batch_Allott where CatalogNo ='0464' ", con);
da.Fill(ds, "temp");
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
lr = ReportViewer1.LocalReport;
lr.ReportPath = "Report1.rdlc";
lr.DataSources.Add(new ReportDataSource("DataSet2", ds.Tables[0]));
}
}


In the above code "BLADE_ERPDataSet" is the name of the datasource and "DataSet2" is the name of the Dataset and this is clearly shown in the image which i took when creating a dataset using ReportData.![enter image description here][1]


![ReportData for adding Dataset]: (http://i.stack.imgur.com/kapR1.jpg)



asked 1 min ago







How to add datasources to RDLC report in visual studio 2010 and pass values to textboxes in that Report

Aucun commentaire:

Enregistrer un commentaire