童真模式启动 2017-11-03 09:31 采纳率: 0%
浏览 727

ASP中,下面RolesManage.aspx.cs中的三小处代码是什么意思来着?

RolesManage.aspx

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RolesManage.aspx.cs" Inherits="SystemManagment_RolesManage" Debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 170px;
        }
        .style3
        {
            width: 100px;
        }
    </style>

    <script>
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <input id="hdnEmailID" type="hidden" name="hdnEmailID" value="0" runat=server />

    <div>

        <table class="style1">
            <tr>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="center">
                    角色管理</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <table class="style1">
                        <tr>
                            <td align="right">
                                角色名称:</td>
                            <td class="style2">
                                <asp:TextBox ID="RoleName" runat="server"></asp:TextBox>
                            </td>
                            <td class="style3">
                                <asp:Button ID="AddRole" runat="server" Text="添加角色" />
                            </td>
                            <td>
                                <asp:Button ID="DeleteRole" runat="server" Text="删除角色" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="center">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="289px" OnRowDataBound="Gridview_RowDataBound">
                        <Columns>
                            <asp:BoundField HeaderText="角色名称" DataField="RoleName" />
                        </Columns>
                        <AlternatingRowStyle BackColor="#D2E9FF" />
                    </asp:GridView>
                </td>
            </tr>
        </table>

    </div>
    </form>
</body>
</html>

RolesManage.aspx.cs

 using System;
using System.Web;
using System.Web.UI.WebControls;

using System.Data;
using System.Configuration;
using System.Web.Security;

public partial class SystemManagment_RolesManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ShowRoles();
        }
    }
    protected void ShowRoles()
    {
        string[] RolesArray = Roles.GetAllRoles();
        DataTable AllRolesTable = new DataTable();
        AllRolesTable.Columns.Add("RoleName",typeof(string));

        foreach (string RoleName in RolesArray)
        {
            DataRow NewRow = AllRolesTable.NewRow();
            NewRow[0] = RoleName;                                                                   //第一处
            AllRolesTable.Rows.Add(NewRow);
        }

        GridView1.DataSource = AllRolesTable;
        GridView1.DataBind();
    }

    protected void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.ID = e.Row.Cells[0].Text;                                                         //第二处1
            e.Row.Attributes.Add("onclick", "GridView_selectRow(this,"+e.Row.Cells[0].Text+")");    //第二处2
        }

    }

    protected void AddRole_Click(object sender, EventArgs e)
    {
        try
        {
            Roles.CreateRole(RoleName.Text);
            ShowRoles();
        }
        catch
        {
            throw;
        }
    }
    protected void DeleteRole_Click(object sender, EventArgs e)
    {
        Roles.DeleteRole(hdnEmailID.Value);                                                         //第三处
        ShowRoles();
    }
}
  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-03 15:50
    关注

    第一处,添加一条role
    第二处
    绑定表的第一列,并且添加客户端点击事件的代码
    最后一处,删除role

    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料