Home > DeveloperSection > Forums > Datagridview dont get update of DataTable
kap roma
kap roma

Total Post:1

Points:7
Posted on    July-25-2014 2:52 AM

 C# C# 
Ratings:


 3 Reply(s)
 1245  View(s)
Rate this:
Hello,
At first i fill of my Main_GUI-Class a DataTable in my "Controler"-Class.
Methode of "Controller"-Class returns DataTable to the GUI-Class:

A Problem is, when i update my DataTable in my "Controler"-Class of some other GUI-Class, my Main_GUI-Class does not show me new Data on the Grid.

That is my Code:

public class Controller{
        DataTable globalDataTable
public DataTable updateData(string param){
        
globalDataTable = sqlClass.getSQLData(); 


}

}

public partial class mainGUI: Form
{
Controller myController;
private void mainGUI_Load(object sender, EventArgs e) {
          myController = new Controller();

                 myGrid.DataSource = myController.updateData("111"); //now Grid shows me Data from DataBase.
}

}

public partial class subGUI: Form
{
Controller control;
        
        public void initilize(Controller cr){
this.control = cr;

       }       

        private void sub_Load(object sender, EventArgs e) {
         
             //...
        }
        
        private void someMethode(){

control.updateData("222"); //now i change my DataTable on "Controller"-Class
//but the mainGUI does not recognize new Data and does not show these on Main-gui
       }


}

How can i solve this problem???
Thanks


Sumit Kesarwani

Total Post:378

Points:2694
Posted on    July-27-2014 11:32 PM

Hi kap roma,

Try this:
public partial class mainGUI: Form
{
Controller myController;
private void mainGUI_Load(object sender, EventArgs e) {
          myController = new Controller();

                 myGrid.DataSource = myController.updateData("111"); //now Grid shows me Data from DataBase.
myGrid.DataBind();
}
}


Hope this will solve your problem

kap roma
kap roma

Total Post:1

Points:7
Posted on    July-28-2014 1:02 AM

Hello :)
Sadly i dont have this Funktion in my Grid.
I have just "DataBinding" and Event "DataBindingComplete".

What can i do?
thx.

Sumit Kesarwani

Total Post:378

Points:2694
Posted on    July-28-2014 3:12 AM

Hi kap, 
 
Whose grid are you using, Windows Form C# or some others??

Don't want to miss updates? Please click the below button!

Follow MindStick