locked
List view dropdown box to update values in SQL database RRS feed

  • Question

  • User-1209441616 posted

    Hi guys,

    Ive got a listivew that has autogenerated CRUD operations that relate to a user table containing user id, password and access level.

    The access level determines if the user is an Admin or regular user and is just an int value at the moment.

    In my list view when someone clicks the Edit button the dropdown box appears with two selectable values, Admin or User.

    in the source of the page I configured the Admin selection to have a value of 1

    and the user selection to have a value of 2.

    My question is how do I define it so that the dropdown updates in the autogenerated edit query, the default textbox that was there has the @accesslevel.

    I am just unsure as to how the value is binded from the drop down goes to in place of the textbox value?

    Here is my listbox code, the default textbox worked fine so the original autogenerated INSERT comand was working.

    <td>
        <asp:DropDownList ID="AccessLevelTextBox" runat="server" > 
            <asp:ListItem Text="Admin" Value="1" />
            <asp:ListItem Text="User" Value="2" />
        </asp:DropDownList>
        <%--<asp:TextBox ID="AccessLevelTextBox" runat="server" Text='<%# Bind("AccessLevel") %>' />--%>
    </td>

      

    Thursday, December 21, 2017 12:34 PM

All replies

  • User1564875471 posted

    I assume that in the database , you will store 1 or 2 for the access level and not the string value.

    You can try this:

    <asp:DropDownList ID="AccessLevelTextBox" runat="server" SelectedValue='<%# Bind("AccessLevel") %>'> 
    Thursday, December 21, 2017 1:20 PM