0

I have created a function to get a userID from a user logging in, which fills a datatable and then I get the UserID from the first row of the datatable.

public int GetUserID (DataTable UserIDTable)
    {

      int UserID = Convert.ToInt32(UserIDTable.Rows[0]["USER_ID"]);
        return UserID;
    }

I then called the function in another form to get the userID from the datatable once the login button is hit.

int UserID =  LoginFunction.GetUserID(DataTable);

I then need to use this UserID to display data in a grid for that user, but I'm not sure how to get the UserID from the form with the login button to the form with the grid.

Alex Hall
  • 304
  • 1
  • 14
  • 1
    Many ways. A public property. Pass it over when you construct the second form. A shared class between the two. What have you tried? – Zer0 Mar 20 '19 at 21:48
  • I have tried creating a public class with a datatable as a parameter but I can't call that in the form I want to use because there is nowhere for a user to enter the username and password. I have also tried putting the userID in a label and then carrying it over into the form but the label is always empty because I cant return an int in the Button_click method – Alex Hall Mar 20 '19 at 21:55
  • [Duplicate 1](http://stackoverflow.com/questions/3062575/), [duplicate 2](http://stackoverflow.com/questions/7800731/), [duplicate 3](http://stackoverflow.com/questions/17032484/), [duplicate 4](http://stackoverflow.com/questions/17836398/), [duplicate 5](http://stackoverflow.com/questions/25316230/), [duplicate 6](http://stackoverflow.com/questions/29092707/)... – Dour High Arch Mar 20 '19 at 21:57

0 Answers0