gridview绑定表头事件
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
DataControlRowType elemType = e.Row.RowType;
if (elemType == DataControlRowType.Header)
{
DropDownList ddl = new DropDownList();
...
ddl.DataSource = dv;
ddl.DataTextField = "jh ";
ddl.DataBind();
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
...
e.Row.Cells[4].Controls.Add(ddl);
}
}
}
动态生成按钮控件
private void CreateButton()
{
Button button = new Button();
button.Text = "Click me";
button.ID="ID1"
button.click += new EventHandle(button_click);
Controls.Add(button);
}
private void button_click(object sender,System.EventArgs e)
{ }
提示runat=server的错误时加下面方法
public override void VerifyRenderingInServerForm(Control control)
{
}