Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to generate RDLC report using asp.net c# by passing parameters in textbox and report want to get display after clicking submit button..

C#
protected void Button1_Click(object sender, EventArgs e)
        {

            string CS = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            using (SqlConnection con = new SqlConnection(CS))
            {

                SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM logindetails WHERE([Username]='" + usertxtbox1.Text + "')", con);
                DataSet ds = new DataSet();
                da.Fill(ds);
                ReportDataSource datasource = new ReportDataSource("DataSet1", ds.Tables[0]);
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(datasource);
                ReportViewer1.LocalReport.Refresh();

            }
        }
Posted
Updated 10-Sep-15 2:18am
v3
Comments
[no name] 10-Sep-15 8:14am    
What you have tried so far that data is not coming for you?
sajan subbiah 10-Sep-15 8:23am    
This was my code and i have textbox to give username as per the query given below... but while debugging.... whole table will get display without giving the username in the textbox... but after giving the username and by clicking the submit button... report got filtered... so my report want to get generate after giving username and clicking submit....


protected void Button1_Click(object sender, EventArgs e)
{

string CS = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{

SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM logindetails WHERE([Username]='" + usertxtbox1.Text + "')", con);
DataSet ds = new DataSet();
da.Fill(ds);
ReportDataSource datasource = new ReportDataSource("DataSet1", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
ReportViewer1.LocalReport.Refresh();

}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900