1)aspx 页面如下
<asp:GridView ID="gvNewsManage" DataKeyNames="NewsID"
runat="server" AutoGenerateColumns="False"
onrowdeleting="gvNewsManage_RowDeleting"
AllowPaging="True"
onrowdatabound="gvNewsManage_RowDataBound">
<PagerSettings Visible="False" />
<Columns>
<asp:BoundField DataField="NewsID" HeaderText="ID" />
<asp:TemplateField HeaderText="选择">
<ItemTemplate>
<asp:CheckBox ID="chkbSelect" runat="server">
</asp:CheckBox>
</ItemTemplate>
<ItemStyle Width="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="新闻标题">
<ItemTemplate>
<asp:Label ID="lblNewsTitle" runat="server" Text='<%# FormatString(Eval("NewsTitle").ToString()) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataNavigateUrlFields="NewsID" DataNavigateUrlFormatString="UpdateNews.aspx?Value={0}"
HeaderText="修改" Text="修改" />
<asp:TemplateField HeaderText="删除">
<ItemTemplate>
<asp:LinkButton ID="lkbtnDelete" OnClientClick="return confirm('您确认删除该记录吗?');" runat="server" CommandName="Delete" Font-Names="宋体" Font-Strikeout="False" Font-Underline="False" ForeColor="Black">删除</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
2) cs 代码段:
protected
void gvNewsManage_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
{ BindData(e.RowIndex); MagicAjax. } { MagicAjax. } }