List<YourClassName> employee = (from emp in dtEmployees.AsEnumerable() where [Your condition] select emp).ToList(); //Assign the dataset to Report Datasource ReportDataSource datasource = new ReportDataSource("DataSet1", employee); //Clear all assiged datasource in reportviewer ReportViewer1.LocalReport.DataSources.Clear(); //Assiged the filtered DataSource to ReportViewer ReportViewer1.LocalReport.DataSources.Add(datasource); //Refrest the ReportViewer ReportViewer1.LocalReport.Refresh();
Thanks, A2H My Blog
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged2"></asp:TextBox> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="750px"> <LocalReport ReportPath="Report1.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="EmptyWebApp.CustomersTableAdapters.AddressTableAdapter"></asp:ObjectDataSource
protected void TextBox1_TextChanged2(object sender, EventArgs e) { //Connection string string CS = ConfigurationManager.ConnectionStrings["AdventureWorks2008R2ConnectionString2"].ConnectionString; //Create connection object using (SqlConnection con = new SqlConnection(CS)) { //Assign query to SQLDataAdapter SqlDataAdapter da = new SqlDataAdapter("select * from Person.Address where City = @City", con); //pass the paramter value da.SelectCommand.Parameters.AddWithValue("@City", TextBox1.Text); //Create a dataset object DataSet ds = new DataSet(); //FIll the dataset da.Fill(ds); //Assign the dataset to Report Datasource ReportDataSource datasource = new ReportDataSource("DataSet1", ds.Tables[0]); //Clear all assiged datasource in reportviewer ReportViewer1.LocalReport.DataSources.Clear(); //Assiged the filtered DataSource to ReportViewer ReportViewer1.LocalReport.DataSources.Add(datasource); //Refrest the ReportViewer ReportViewer1.LocalReport.Refresh(); } }
Feel free to share informations. mail Id ' adityagupta200@gmail.com Thanks
Login to post response