Click here to Skip to main content
15,885,953 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,

I`m having problem with ShowDialog() when I make some changes. I`ll try to explain whole situation provided with adequate code.

So I`m having form for some calculation, lets call it CalcForm. On that form I have button which redirect me to another form DetailsForm(datagridview with some information). Here is the code:
C#
 frmNovartisALL frm = new frmNovartisALL();
            frm.ShowDialog();
            this.product = frm.product;
            if (product == null)
            {
                return;
            }
            else
            {
             

                txt_price.Text = this.product.Price1.ToString();
                txt_price1.Text = this.product.Price2.ToString();
                txt_price2.Text = this.product.Price3.ToString();
        
//
        
            }


When I click on linkbutton "Change" in gridview, whit this code
C#
int id = (int)gv_novartis.CurrentRow.Cells["ID"].Value;
           product = Products.SearchByID(id);
           this.Close();



all information about selected row are populated in first form.
And everything works well. When I change some information in CalcForm and save them, and when I again open DetailsForm all changed information are there also. But, here is the problem- if I click again on linkbutton in gridview- in CalcForm are shown information before editing. Only way to make it work is to restart application.
I now its bit confusing, but if you have any ideas- plese let me now.

Just to say also- everything is updated well in database.
Posted

1 solution

Hi Sounds like you not refreshing the view with data after the database updated.

If you think of the design like this:

View <--> Model <--> Database

View (i.e. your link button) tell the model to update the database, the model updates the database and replies to view with the updated value.

This way you can be sure what is shown in the view is what is stored in the database.

Jegan
 
Share this answer
 
Comments
ellisbay 21-Feb-13 9:15am    
But in gridview are shown updated fields.
Jegan Thiyagesan 21-Feb-13 9:36am    
Are you not binding the data source to the grid view?

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