Link to home
Start Free TrialLog in
Avatar of ronin83
ronin83

asked on

autopostback radiobuttonlist in a formview isn't updating DB

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?
Avatar of spprivate
spprivate
Flag of United States of America image

Put a break point and see if it is executing the update statement.
Avatar of ronin83
ronin83

ASKER

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?
Can you share your SqlDataSource code as well
Avatar of ronin83

ASKER

<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>
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial