Click here to Skip to main content
15,911,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
plz help me any body when we close child window then the parent window automatic refresh and also give me when we click the the button the window form refresh and plz tell me when we insert data the gridview database refresh and show new inserted data plz tell me..some idea or code..we c# window application
Posted
Comments
Prasad_Kulkarni 9-Mar-12 0:33am    
Are you using MDI Form?

In form load event of parent window just Reload the data. Write a function for reloading the data from database. So whenever you close any child window and open the parent window the data will be reloaded and you will get the Updated records.

Or you can call the reload function in form_Activated event if your parent form is opened and behind the child form. So whenever you close the child form the parent form will be activated and your reload data function will be called giving you the updated records.

Hope You Got An Idea Through This. If not then ask me again. I will help to solve your problem
 
Share this answer
 
v2
You need to give some more information. Is this WPF, and you need to refreash?

One idea is to use an observable collection for the source for the grid. This will automatically cause the rows to refresh when new data is added. Another option if this is WPF (may work in other cases) is to have the property only have a get property, and append the get return statement with a ToList(). This automatically assures that the address will change so that when a PropertyChange event occures, the grid will be refreshed. Again, I am assuming WPF, this may also work in other environments.
 
Share this answer
 
Comments
Khan Rashid 9-Mar-12 0:49am    
am using Window form Application in c#
XML
Add following code in child form

<input type="button" value="Close" onclick="javascript:CloseThis()" />

<script type="text/javascript">
        function CloseThis() {
            window.parent.closeChild(this);
        }
</script>


Add following code in parent form.
<asp:Button ID="btnReload" runat="server" CausesValidation="false" Text="Button"
                        Style="display: none;" OnClick="btnReload_Click" />

<script type="text/javascript">
        function closeChild(box) {
            $.fn.colorbox.close();
        }
        function reloadParent(val) {
            var btn = document.getElementById('<%=btnReload.ClientID%>');
            document.getElementById('<%=hdstatus.ClientID%>').value = val;
            btn.click();
        }
</script>
 
Share this answer
 
Comments
Aniket Yadav 9-Mar-12 1:18am    
Hello Mukund, Rashid is using windows application...
Khan Rashid 9-Mar-12 4:22am    
good work but am using window application in c#
not develop web application in asp.net
i am not clear with your question but still let me try...


if you want to refresh the page simply make a object of parent form and call it.. by doing this it will re initialised the controls on form.

or if you dont want to refresh again and agian just make its object publically and call the object again and again... in this case constructor part of parent form will not initailize....

hope you get it...
 
Share this answer
 
Hi dear,

When you close the child windows then exceute refresh function. when you insert data in to datagried then execute refresh function.

Example: When you close the child windows then exceute refresh function.

private void Close_Click(object sender, EventArgs e)
{
this.Close()
Refresh(); // execute refresh function.
}

//-------------------------------------------------
Example : when you insert data in to datagried then execute refresh function.

private void Insert_Click(object sender, EventArgs e)
{
SQL = "Insert into Datagried" // Your desire work is complete then refresh function is execute.

Refresh(); // execute refresh function.
}
 
Share this answer
 
 
Share this answer
 
v2

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