Want to build the ChatGPT based Apps? Start here
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Oladotun Obileye
2.1k
98
15.5k
How to pass value from a control to another in C#
May 26 2019 5:10 PM
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;
}
Reply
Answers (
7
)
How to work with int and datetime in C#
Daily, Weekly, Monthly and yearly hotel booking report.