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="Ra dioButtonL ist1_Selec tedIndexCh anged">
<asp:ListItem>Nobody</asp: ListItem>
<asp:ListItem>Friends</asp :ListItem>
<asp:ListItem>Watching</as p:ListItem >
<asp:ListItem Value="">Anybody</asp:List Item>
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_SelectedI ndexChange d(object sender, EventArgs e)
{
privacy.Update();
}
i don't get errors, just no DB updates. what am i missing?
<asp:RadioButtonList AppendDataBoundItems="True
<asp:ListItem>Nobody</asp:
<asp:ListItem>Friends</asp
<asp:ListItem>Watching</as
<asp:ListItem Value="">Anybody</asp:List
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_SelectedI
{
privacy.Update();
}
i don't get errors, just no DB updates. what am i missing?
Put a break point and see if it is executing the update statement.
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
ASKER
<asp:SqlDataSource ID="privacy" runat="server"
ConnectionString="<%$ ConnectionStrings:Connecti onString %>"
OldValuesParameterFormatSt ring="orig inal_{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>
ConnectionString="<%$ ConnectionStrings:Connecti
OldValuesParameterFormatSt
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"
<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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.