Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello myfriends.
i want to add an button and a lable to the table cells.
when i click on button text that present on lable must be changed
i write this code but do not work :

C#
protected void Button2_Click1(object sender, EventArgs e)
    {
        for (int i = 1; i <= int.Parse(TextBox1.Text); i++)
        {
            TableRow tr = new TableRow();
            for (int j = 1; j <= int.Parse(TextBox2.Text); j++)
            {
             TableCell tc = new TableCell();
             Label  lbl= new Label();
             Button btn = new Button();
             btn.Text = (i*j).ToString();
             btn.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btn, Click"));
             if (Request["__EVENTARGUMENT"] == "Click")
                {
                    lbl.Text = (i * j).ToString();
                }        
                tc.Controls.Add(lbl);
                tc.Controls.Add(btn);
                tr.Controls.Add(tc);
            }
            Table1.Controls.Add(tr);
        }
        
    }

can you help me?
my mail : ali.daroudi@gmail.com
Posted
Updated 30-Apr-12 0:43am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900