自定义事件问题
从后台生成一个lbtn,然后自己定义一个事件,当lbtn接下时响应自定义事件如下:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")//执行删除
{
}
if (e.CommandName == "detail")//查看详细
{
Panel1.Visible = true;
string[] detailcolumns = new string[] { "id" };
string[] detailcatption = new string[] { "编号" };
string rowno=GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text;
PlDisplay(tbname, detailcolumns, detailcatption,rowno );
}
}
private void PlDisplay(string table, string[] detailcolumns, string[] detailcatption, string id)
{
Label[] lb = new Label[detailcatption.Length];
TextBox[] tb = new TextBox[detailcolumns.Length];
for (int i = 0; i < detailcatption.Length; i++)
{
lb[i] = new Label();
lb[i].ID = "lb" + i.ToString();
lb[i].Text = " " + detailcatption[i] + ":";
tb[i] = new TextBox();
tb[i].ID = detailcolumns[i];
tb[i].Text = detailcolumns[i];
Panel1.Controls.Add(lb[i]);
Panel1.Controls.Add(tb[i]);
}
LinkButton lbtnOk = new LinkButton();
lbtnOk.ID = "lbtnOk";
lbtnOk.Text = "保存";
lbtnOk.Click += new EventHandler(lbtnOk_Click); //订阅不上吗?
Panel1.Controls.Add(lbtnOk);
}
protected void lbtnOk_Click(object sender,EventArgs e) //这个函数没返应
{
Response.Write(clsFun.MessageInfo("aaa"));//消息框
}
为什么不响应??就算响应该怎么传id进来
[此贴子已经被作者于2006-12-9 11:54:19编辑过]