复制代码 代码如下:
<asp:GridView runat="server"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID"
BorderColor="#333" BorderStyle="solid" BorderWidth="1"
OnRowDeleting="PublicGridRowDeleting"
GridLines="None" ForeColor="#333333">
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="false"
ReadOnly="True"
SortExpression="ID" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="删除" ShowHeader="False">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:LinkButton runat="server"
CausesValidation="False" CommandName="Delete" OnClientClick="return confirm('您确认删
除?');" Text="删除"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333"
/>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"
/>
<HeaderStyle BackColor="#5A799C" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<EmptyDataTemplate>
日志库暂时为空!
</EmptyDataTemplate>
</asp:GridView>
复制代码 代码如下:
protected void PublicGridRowDeleting(object sender, GridViewDeleteEventArgs e)
{
string strID = GridLog.DataKeys[e.RowIndex].Value.ToString();//strID就是该行的ID
string strSQL = "Delete from table " +
" WHERE id = " + strID;
//执行删除
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT
LANGUAGE='javascript'>alert('删除成功!');</script>");
GridBind();
}
新闻热点
疑难解答
图片精选