gridview控件里的添加删除修改按钮的事件在哪里写啊?
发布网友
发布时间:2022-07-24 14:22
我来回答
共3个回答
热心网友
时间:2023-10-09 10:01
客户端代码
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="gridview"
Width="95%" AllowPaging="True" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing">
<Columns>
<asp:BoundField DataField="id" HeaderText="编号" />
<asp:BoundField DataField="GetMan" HeaderText="获奖者" />
<asp:BoundField DataField="GaTime1" HeaderText="获奖时间" />
<asp:BoundField DataField="GaName" HeaderText="荣誉名称" />
<asp:BoundField DataField="GetDep" HeaderText="授予部门" />
<asp:BoundField DataField="GetTime1" HeaderText="授予时间" />
<asp:CommandField HeaderText="修改" ShowEditButton="True" EditText="修改" />
<asp:TemplateField HeaderText="删除">
<ItemTemplate>
<asp:LinkButton ID="linDel" runat="server" CommandName="delete" OnClientClick="return confirm('是否删除')">删除</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Visible="False" />
</asp:GridView>
服务端 代码
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
zsdel.Open("delete Glory where id=" + GridView1.Rows[e.RowIndex].Cells[0].Text);
zsdel.Close();
RegisterStartupScript("", "<script>alert('删除成功')</script>");
Bind("select *,convert(varchar(10),GaTime,120) as GaTime1,convert(varchar(10),GetTime,120) as GetTime1 from Glory");
}
热心网友
时间:2023-10-09 10:01
如果没有,可以自己写个类,继承gridview的类,并响应按钮消息
热心网友
时间:2023-10-09 10:02
打开控件的属性窗口 然后点击那个小闪电 所有事件都出来了 我说的是VS2005