DATAGRIDVIEW DONT GET UPDATE OF DATATABLE

kap roma

Total Post:1

Points:7
Posted by  kap roma
C# 
C#
 1465  View(s)
Ratings:
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
  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Datagridview dont get update of DataTable

    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

  1. kap roma

    Post:1

    Points:7
    Re: Datagridview dont get update of DataTable

    Hello :)

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

    What can i do?
    thx.

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Datagridview dont get update of DataTable

    Hi kap, 

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!