How to pass value from child form to parent form
-
I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz
-
I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz
Someone may suggest modifying the constructor of the forms, or having a method to pass the data, etc. However, Pete O'Halon with slap anyone that suggests that. You should implement the Model-view-controller design pattern.[^] Read up on it. It'll make you a better "developer" :)
I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
-
I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz
This is help for u.. use this stmt in child window javascript window.returnValue=document.getElementById('<%=hfldConCatStr.ClientID%>').value; use this in parent window var retVal=window.showModalDialog('dsfdf.aspx');
-
I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz
Ejaz Bhai! try this, Its simple to implement.... in Parent Form use this:
dim myVal as integer Public Property SetVal() As Integer Get Return myVal End Get Set(ByVal value As Integer) myVal = value End Set End Property
in child form: dim parentObj as [parentForm] parentObj.SetVal = [Any Integer Valu] now close child form and use variable 'myVal' in parent form as output from child form.colgateas900197
-
I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz
I normally make data and view objects and every view can access the data so it can easily be shown and changed. The data object is globally and unique. If data gets changed you got to trigger an update, in your case check whether the dialog returns with OK => Reload from data object.
Greetings from Germany