I have a form1 and form2. in form1 there is a textbox which consist any department. and the another textbox consist room related to only these depatment. besides room textbox there is a searchbutton. which opens form2. form 2 consist a gridview. and this grid view should be filled by only selected department in form1. and when this form2 opens then in grid view also shows room is booked or free...

Use Querystring concept .pass department and rooms as string type to second form.

Step1: On Button Click- form1
Response.Redirect("Form2.aspx?Dept=" + Textbox1.Text +"&Rooms="+Textbox2.Text);
Step2 : Bind Grid --Form2
String Dept=Request.QueryString["Dept"].tostring();
String Rooms=Request.Querystring["Rooms"].tostring();
Step 3: Pass these two variables to Stored Procedure.


I thought this will help you.
thanks

I am new in coding plz clear how it will done and i have not use anything this is for c# windows applicaton.

I have a question am new in programming C# and I have tried to make a group box invisible in form2 from another form how will dis be done.
this is me code.pla help
private void button1_Click()
{
form2 frm2=new form2();
fr2.show();
frm2.groupbox.visible=false;
}

I can only discuss concept as you did not provide any code.

I think, what you are trying to do is to
- transfer data between 2 forms.
- form2 should know what data is selcted in form1

Almost what emmyt told is recommended for opening one from using another.

private void button1_Click()
{
form2 frm2=new form2();
fr2.show();
frm2.groupbox.visible=false;
}

Now your form is opened but no data transfer has been done. So I will recommend you to change the constructor of form2 so that it accepts data from form1.

///In form1
t_Data aData = GetSelectedRowData(DataGridViewInstanceOfForm1) //write your fown function)
form2 frm2=new form2(aData);
fr2.show();
frm2.groupbox.visible=false;
//In form2, use this constructor
public Form2(t_Data aData)
{
}
This article has been dead for over six months. Start a new discussion instead.