Good day everyone, please i am trying to count the number of records of a datagridview(dtuserpro) in a usercontrol profile and pass it to a label in another usercontrol dashboard but i get no value.
- public partial class userprofile : UserControl
- {
- private string count1;
- public string Countt
- {
- get { return count1; }
- set { count1 = value; }
- }
- public userprofile()
- {
- InitializeComponent();
- }
- SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\odt\Documents\Loanapp.mdf;Integrated Security=True;Connect Timeout=30");
- DataTable dt = new DataTable();
- private void profile_Load(object sender, EventArgs e)
- {
- int count = ((DataTable)this.dtuserpro.DataSource).Rows.Count;
- lblcount.Text = count.ToString();
- Countt = lblcount.Text;
- }
- private void dashboard_Load(object sender, EventArgs e)
- {
- userprofile up = new userprofile();
- metroLabel1.Text = up.Countt;
- }
7 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted May 28, 2019, 1:38 AM
Oladotun ObileyePosted May 28, 2019, 4:52 AM
Rajanikant HawaldarPosted May 28, 2019, 1:16 AM
Oladotun ObileyePosted May 27, 2019, 5:27 PM
Aniket RanaPosted May 27, 2019, 1:39 AM
Ronika JencyPosted May 27, 2019, 12:37 AM
https://www.dotnetcurry.com/ShowArticle.aspx?ID=155
Jayakumar BalasubramaniamPosted May 26, 2019, 8:18 PM