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
Gabriel olayinka
NA
119
4.7k
creating controls in c#
Apr 4 2018 2:11 AM
i"m creating LinkLabel control using database value... this is working fine ....
but why is it that the event handler i assigned to different controls are only show the same thing .... not different actions ... thanks... here is my code
void
createControls()
{
try
{
con.Open();
// Read specific values in the table.
SqlCommand cmd =
new
SqlCommand(
"select * from PAGES "
, con);
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
ds =
new
DataSet();
da.Fill(ds,
"CLASSROOMS"
);
for
(count=0; count <= ds.Tables[0].Rows.Count - 1; count++)
{
CLASS_NAME = ds.Tables[0].Rows[count][
"CONTROL_NAME"
].ToString();
// rdr.GetString(3);
CONTROL_TYPE = ds.Tables[0].Rows[count][
"CONTROL_TYPE"
].ToString();
// rdr.GetString(2);
CONTROL_TEXT = ds.Tables[0].Rows[count][
"CONTROL_TEXT"
].ToString() +
"("
+ NUMBER_PER_CLASS +
")"
;
CONTROL_LOCATION = (
int
)ds.Tables[0].Rows[count][
"CONTROL_LOCATION"
];
CONTROL_HEIGHT = (
int
)ds.Tables[0].Rows[count][
"CONTROL_HEIGHT"
];
CONTROL_NAME = ds.Tables[0].Rows[count][
"CONTROL_NAME"
].ToString();
LinkLabel lk =
new
LinkLabel();
Controls.Add(lk);
lk.Text = CONTROL_TEXT;
lk.Location =
new
Point (CONTROL_HEIGHT,CONTROL_LOCATION);
lk.Name = CONTROL_NAME;
lk.AutoSize=
true
;
lk.Click += (s,e)=> { MessageBox.Show(CONTROL_NAME.ToString()); };
lk.Show();
}
i want a messageBox to pop up and show the control Name once the control is clicked...... but i"m getting the same Control name for all the controls
Reply
Answers (
2
)
Deploying Windows Forms Applications in IIS like Web App.
Create MD5 Password Encryption in MVC