添加TemplateField 然后gridview编辑模板 找到添加的那一列》》 往itemTemplate里面拖一个控件就好了
<asp:TemplateField><ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="xq"
CommandArgument='<%# Bind("Id") %>'>[详情]</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
上面是源码 CommandName和CommandArgument跳转的时候需要用到
用<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>占位protected void Page_Load(object sender, EventArgs e)
{
LinkButton LinkButton1 = new LinkButton()
LinkButton1.Text = "LinkButton1"
LinkButton1.Command += new CommandEventHandler(LinkButton1_Command)
PlaceHolder1.Controls.Add(LinkButton1)
}
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
Response.Write("<script>alert('你点击了我')</script>")
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)