TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
Oladotun Obileye
NA
98
19.3k
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.