15
2012
05

gridview中加一列操作,点击审核,修改数据库数据并且将审核改为已审核

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
GridLines="None" UseAccessibleHeader="False" HeaderStyle-Height="30px"
RowStyle-Height="25px" OnRowDataBound="GridView1_RowDataBound">
    <HeaderStyle HorizontalAlign="Center" Height="30px" />
    <RowStyle Height="25px" />
    <Columns>
        <asp:TemplateField HeaderText="审核项名称" Visible="false">
            <ItemTemplate>
                <asp:Label ID="name" runat="server" Text='<%# Eval("name").ToString().Trim() %>'>
                </asp:Label>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Center" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="管理">
            <ItemStyle HorizontalAlign="Center" Width="80px" />
            <ItemTemplate>
                <asp:LinkButton ID="LabelText" runat="server" Text="" OnClick="LabelText_Click">
                </asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <EmptyDataTemplate>
        <div align="center">
            <asp:Label ID="labelnull" runat="server" Text="暂时没有您需要的信息">
            </asp:Label>
        </div>
    </EmptyDataTemplate>
    <AlternatingRowStyle BackColor="#F0F9FF" />
</asp:GridView>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs
e) { //首先判断是否是数据行 if (e.Row.RowType == DataControlRowType.DataRow) { string
name = ((Label) e.Row.FindControl("name")).Text; ((LinkButton) e.Row.FindControl("LabelText")).Attributes.Add("onclick",
"javascript:return confirm('你确认要审核该信息吗:" + name.Trim() + "')"); }}LabelText_Click()执行该后台程序进行审核

« 上一篇下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。