Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have a windows form application where a user inputs a value on a particular form (A) and that same value is to be used to generate a report which is on another form (B). The dataset for the report is not loading because it needs the value of the textbox in form A. Please, how can I do this? It's giving me an error of "No overload for method Fill takes 1 arguments" please help
this the code
C#
public string entmatno
       {
           get { return entmatno.Text; }
       }
private void Resultpage_Load(object sender, EventArgs e)
        {

            // TODO: This line of code loads data into theCourseInfoDataSet.COURSEINFO_TBL; table. You can move, or remove it, as needed.
            this.COURSEINFO_TBLTableAdapter.Fill(this.CourseInfoDataSet.COURSEINFO_TBL, entmatno.text);

            this.reportViewer1.RefreshReport();
        }
Please note the form is fired by a button click in form A
Posted
Updated 20-Nov-13 4:50am
v4
Comments
thatraja 20-Nov-13 10:12am    
Include the code in your question

You cannot reference a textbox on form A inside the code for form B. form B has no way to access that control.

You need to pass the value in the textbox on form A to form B. There are a number of ways to do that.

Check out this article on codeproject
Passing Data Between Forms[^]
 
Share this answer
 
Comments
Jerofad 21-Nov-13 4:25am    
read your article but I'm not trying to assign it to a label. what i want to do is to use it to get data from my dataset (the inputed text is like a foreign key in my table). Ive used it as a paremeter to get my datas successfully but i want to use it to generate a report which would be displayed on another form.
You need to pass the value of the text box on form 1 to form 2 so form 2 can use it to get the dataset.

I think you need to do something like this (using the "constructor approach" from the article i suggested)
http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms


C#
//in form1:

private void button1_Click(object sender, System.EventArgs e)
{
    //open form 2 and pass it the value of the textbox on form 1
    Form2 frm=new Form2(entmatno.Text);
    frm.Show();
}


//in Form2:
String entmatno = "";

public string Entmatno
       {
           set { entmatno = value; }
           get { return entmatno; }
       }


public Form2(string entmatnoFromForm1)
{
  InitializeComponent();
  Entmatno=entmatnoFromForm1);
}

private void Resultpage_Load(object sender, EventArgs e)
        {

            // TODO: This line of code loads data into theCourseInfoDataSet.COURSEINFO_TBL; table. You can move, or remove it, as needed.
            this.COURSEINFO_TBLTableAdapter.Fill(this.CourseInfoDataSet.COURSEINFO_TBL, Entmatno);

            this.reportViewer1.RefreshReport();
        }
 
Share this answer
 

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