autopostback radiobuttonlist in a formview isn't updating DB

ronin83
ronin83 used Ask the Experts™
on
i have a formview with a radiobutton list inside of it. the radiobuttonlist code is

<asp:RadioButtonList AppendDataBoundItems="True" SelectedValue='<%# Bind("displayname") %>' AutoPostBack="True" ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
                                        <asp:ListItem>Nobody</asp:ListItem>
                                        <asp:ListItem>Friends</asp:ListItem>
                                        <asp:ListItem>Watching</asp:ListItem>
                                        <asp:ListItem Value="">Anybody</asp:ListItem>

the value returned from DB is NULL, so anybody gets auto selected on page load. this works fine. when i click another option, i see a postback on the page and the new value is selected, but when i refresh the page, the db change has not been made and its back to 'anybody'.

here's my sqldatasource updatecommand for this formview

UpdateCommand="UPDATE [profiles] SET [displayname] = @displayname, [displayage] = @displayage, [displaygender] = @displaygender, [displaylocation] = @displaylocation, [displaynetwork] = @displaynetwork, [showuploads] = @showuploads, [displaycomments] = @displaycomments, [showstatuses] = @showstatuses, [whosearch] = @whosearch, [showprofiledash] = @showprofiledash, [displaydashcomments] = @displaydashcomments, [showfriends] = @showfriends, [whomessage] = @whomessage, [whowatch] = @whowatch WHERE [pid] = @original_pid">

here's the .cs behind the radiobuttonlist autopostback

protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        privacy.Update();
    }

i don't get errors, just no DB updates. what am i missing?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Put a break point and see if it is executing the update statement.

Author

Commented:
i'm actually entirely self taught and never got around to teaching myself breakpoints. i don't even know how to add one, or how to view whatever results they give you. would it be easy to explain real quick?
Top Expert 2013

Commented:
Can you share your SqlDataSource code as well

Author

Commented:
<asp:SqlDataSource ID="privacy" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [profiles] WHERE ([username] = @username)"
        UpdateCommand="UPDATE [profiles] SET [displayname] = @displayname, [displayage] = @displayage, [displaygender] = @displaygender, [displaylocation] = @displaylocation, [displaynetwork] = @displaynetwork, [showuploads] = @showuploads, [displaycomments] = @displaycomments, [showstatuses] = @showstatuses, [whosearch] = @whosearch, [showprofiledash] = @showprofiledash, [displaydashcomments] = @displaydashcomments, [showfriends] = @showfriends, [whomessage] = @whomessage, [whowatch] = @whowatch WHERE [pid] = @original_pid">
        <UpdateParameters>
            <asp:Parameter Name="displayname" Type="String" />
            <asp:Parameter Name="displayage" Type="String" />
            <asp:Parameter Name="displaygender" Type="String" />
            <asp:Parameter Name="displaylocation" Type="String" />
            <asp:Parameter Name="displaynetwork" Type="String" />
            <asp:Parameter Name="showuploads" Type="String" />
            <asp:Parameter Name="displaycomments" Type="String" />
            <asp:Parameter Name="showstatuses" Type="String" />
            <asp:Parameter Name="whosearch" Type="String" />
            <asp:Parameter Name="showprofiledash" Type="String" />
            <asp:Parameter Name="displaydashcomments" Type="String" />
            <asp:Parameter Name="showfriends" Type="String" />
            <asp:Parameter Name="whomessage" Type="String" />
            <asp:Parameter Name="whowatch" Type="String" />
            <asp:Parameter Name="original_pid" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ProfileParameter Name="username" PropertyName="username" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
Top Expert 2013
Commented:
Are you setting value for your Parameter displayname anywhere in code-behind ...?
If NOT then modify your updateParamter accordingly.
Change ---
<asp:Parameter Name="displayname" Type="String" />
To---
 <asp:ControlParameter ControlID="RadioButtonList1" Name="displayname"
                    PropertyName="SelectedValue" Type="String" />

What the above code does is it tells SqlDataSource from where to get the UpdateParameter "displayname" i.e. here
ControlID="RadioButtonList1" and   PropertyName="SelectedValue"


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial