I have a Repeater that will post a User Name, their permission levels, and a remove button.
The permission level is suppose to sit in a drop down list. The default value is suppose to be what ever the user currently has.
IE
USER A, Guest
USER B, Group Member
USER C, Group Admin
Changing these will eventually fire a sql command to change them in the Database. But that isn’t a problem, I know how to do that.
The values are coming from the repeater source.
ASP CODE:
<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>
I am looking to pass the PID into the Dropdownlist and make that the selected choice
First, I believe you did not intend to label this asp-classic, but rather asp.net. No big deal with that.
I would recommend using
OnItemDataBound. Something like this to get you started:Alternatively, I believe you can bind to the control itself using markup:
Good luck.