得取数据的问题???????
LinkButton lkb = new LinkButton();
lkb.Text= "test ";
lkb.Click += new EventHandler(LinkButton_Click);
LinkButton lkb2 = new LinkButton();
lkb2.Text = "test2 ";
lkb2.Click += new EventHandler(LinkButton_Click);
protected void LinkButton_Click(object sender, EventArgs e)
{
Response.Write( "按到了 ");
}
现在我想知道怎么分别是由那个LinkButton传来的,应该怎么来区别,例如字符或数据之类的取得???不会做,请教大家!!谢谢!!!!
------解决方案--------------------你要先指定它的ID
LinkButton lkb = new LinkButton();
lkb.ID = "mytest1 ";
lkb.Text = "test ";
lkb.Click += new EventHandler(LinkButtonx_Click);
this.form1.Controls.Add(lkb);
LinkButton lkb2 = new LinkButton();
lkb2.ID = "mytest2 ";
lkb2.Text = "test2 ";
lkb2.Click += new EventHandler(LinkButtonx_Click);
this.form1.Controls.Add(lkb2);
然后这样得到
protected void LinkButton_Click(object sender, EventArgs e)
{
Response.Write( "按到了 "+((LinkButton)sender).ID);
}