1 LinkButton label;
2 for (int i = 0; i < ((seat.Rows.Count % 10) == 0 ? (seat.Rows.Count / 10) : (seat.Rows.Count / 10) + 1); i++)
3 {
4 for (int j = 0; j < 10; j++)
5 {
6 label = new LinkButton();
7 if (int.Parse(seat.Rows[(i * 10 + j)]["seatstate"].ToString()) == 1)
8 {
9 label.BackColor = Color.Green;
10 }
11 else
12 {
13 label.BackColor = Color.Red;
14 }
15 label.Width = 60;
16 label.Height = 25;
17 label.ID = "lbl" + (j + 1).ToString() + "_" + (i + 1).ToString();
18 label.Text = (j + 1).ToString() + "-" + (i + 1).ToString();
19 label.Style["Position"] = "Absolute";
20 label.Style["Top"] = i * 25 + 25 + "px";
21 label.Style["Left"] = j * 60 + 60 + "px";
22 label.Visible = true;
23 label.Click += new EventHandler(lblSeat_Click);
24 penSeat.Controls.Add(label);
25
26 }
27
28
29 public void lblSeat_Click(object sender, EventArgs e)
30 {
31 this.Page.ClientScript.RegisterStartupScript(GetType(),"","window.alert('ok');",true);
32 }
Qyouu
白猪掌柜的