3个回答
2013-06-08
展开全部
客户端代码
<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");
}
<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");
}
2013-06-08
展开全部
如果没有,可以自己写个类,继承gridview的类,并响应按钮消息
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-08
展开全部
打开控件的属性窗口 然后点击那个小闪电 所有事件都出来了 我说的是VS2005
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询