dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] asp.net search and report viewer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2015
    Posts
    95

    Resolved [RESOLVED] asp.net search and report viewer

    hello ,
    when I start the webform its working show the data from report viewer
    but when I search by name or civilid am getting error ( A data source instance has not been supplied for the data source 'DataSet1'. )

    code
    Code:
      protected void TextBox1_TextChanged(object sender, EventArgs e)
            {
                string mainconn = ConfigurationManager.ConnectionStrings["kankonConnectionString1"].ConnectionString;
                SqlConnection sqlconn = new SqlConnection(mainconn);
                sqlconn.Open();
                SqlCommand sqlcomm = new SqlCommand();
                string sqlquery = "Select * from [dbo].[Table_infoname] where name LIKE '%' + @name +'%' OR civilid LIKE '%' + @civilid +'%' ";
    
                sqlcomm.CommandText = sqlquery;
                sqlcomm.Connection = sqlconn;
                sqlcomm.Parameters.AddWithValue("name", TextBox1.Text);
                sqlcomm.Parameters.AddWithValue("civilid", TextBox1.Text);
    
                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter(sqlcomm);
                GridView1.DataSourceID = null;
               sda.Fill(dt);
               GridView1.DataSource = dt;
                GridView1.DataBind();
                sqlcomm.ExecuteNonQuery();
               ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report1.rdlc");
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("kankon", dt));
                ReportViewer1.LocalReport.Refresh();
                sqlconn.Close();
            }
    Attached Images Attached Images   

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2015
    Posts
    95

    Re: asp.net search and report viewer

    I just fix it

    Code:
    ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width