给控件添加事件

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 }
沧海一幻觉
浏览 461回答 6
6回答

Qyouu

能否把问题说的具体点,没有理解您的意思?

白猪掌柜的

可怜的楼主被微软的这种开放捆绑了...... 还有服务端控件.....灵活性太差了.....
打开App,查看更多内容
随时随地看视频慕课网APP