sir i've a problem. i want that if i click on link in gridview then the values for that row should come in text box in parent form. please help me how i can do this. i'm using VB.Net2005

8 Years
Discussion Span
Last Post by bala24

Well you can use javascript for this purpose.
You can use the window.parent property to access any control on the parent window.

Just call this function on the click of the link and this should solve your purpose.


Sorry Buddy,
My mistake...the property is window.opener and not window.parent like I mentioned earlier.


sir this thing is not working. and please tell me how can i work in case of web form.


Well It is supposed to work in case of the webform only .

Can you post me the code as to how you are doing it.
I think you are doing something wrong somewhere.


this is d coding at search button on the main web form from where i'm opening a pop up window for a search. i've made global variables search tring, table name and calling form.

Protected Sub cmdSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
      Session("SearchString") = "StateCode, StateName"
      Session("TableName") = "StateMaster"
      Session("CallingForm") = Me

      cmdSearch.Attributes.Add("onclick", "window.open('Search.aspx',null,'fullscreen=0,left=508,top=150,height=400,width=350,menubar=no,toolbar=no,resizable=no');return true;")

     End Sub

in the search form i've populated a grid view which has select button, on the select change button

Session("ReturnValue") = GridView1.SelectedRow.Cells(1).Text
      Response.Write("<script language='javascript'>{self.close();}</script>")
end sub

where do i code window.opener?

please sugest what else can i do?


Try using the following piece of code before self.close();

window.opener.document.getElementById('<your txtbox name>').text=<the value u want to return>;

But I doubt if you would be able to get the datagrid selected row value in a script.
You have to create the id on the fly and use that.
Alternatively try getting the value from that session variable instead.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.