我有一个中继器,它将发布一个用户名、他们的权限级别和一个删除按钮。权限级别假设位于下拉列表中。默认值假设是用户当前拥有的值。
IE
用户 A,访客
用户 B,组成员
用户 C,组管理员
更改这些最终将触发 sql 命令以在数据库中更改它们。但这不是问题,我知道该怎么做。
这些值来自转发器源。
ASP 代码:
<asp:SqlDataSource ID="User_Repeater_Source" runat="server" ConnectionString="<%$ ConnectionStrings:app_migrationConnectionString %>"
SelectCommand="SELECT Membership.*, Users.Email, Users.Last_Name + ', ' + Users.First_Name + ' (' + Membership.User_ID + ')' as User_String FROM Membership INNER JOIN Users ON Users.User_ID = Membership.User_ID INNER JOIN Permission_Levels ON Permission_Levels.PID = Membership.PID WHERE GID = @GID">
<SelectParameters>
<asp:ControlParameter ControlID="Group" DefaultValue="-1" Name="GID" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="User_PL_Source" runat="server" ConnectionString="<%$ ConnectionStrings:app_migrationConnectionString %>"
SelectCommand="SELECT * FROM Permission_Levels"></asp:SqlDataSource>
...
<td>
<div class="e_Title">
Edit Group Permission:</div>
<br />
<asp:Repeater ID="User_Repeater" runat="server" DataSourceID="User_Repeater_Source">
<HeaderTemplate>
<table class="e_Repeater">
<tr>
<th>
User:
</th>
<th>
Permission Level:
</th>
<th>
Remove User:
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<a href='<%#"mailto:" + DataBinder.Eval(Container.DataItem, "Email") %>'>
<%#DataBinder.Eval(Container.DataItem, "User_String" %></a>
</td>
<td>
<asp:DropDownList ID="User_PL" runat="server" DataSourceID="User_PL_Source" DataTextField="Name"
DataValueField="PID" AutoPostBack="true">
</asp:DropDownList>
</td>
<td>
<asp:Button ID="Submit_User_Remove" runat="server" Text="Remove Permission" OnCommand="Remove_User_Permission"
CommandArgument='<%# Eval("AID")%>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
我希望将 PID 传递到下拉列表中并使其成为选定的选项