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();
-
- 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();
- CONTROL_TYPE = ds.Tables[0].Rows[count]["CONTROL_TYPE"].ToString();
- 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