T
Trevor Bezotte
Hi,
I'm new to asp.net. I am having trouble updating and displaying a profile property through a dropdownlist. I believe the problem has something to do with autoeventwireup but I'm not sure. If I change the selection in the dropdownlist and click Button1, the profiles database gets updated and the control shows my new selection, but when I browse to a different page and come back to this page, the dropdownlist gets set back to the default selection (the first item in the list). Why is this happening and how do I fix it?
Here is my code:
<%@ Page Language="VB" MasterPageFile="~/AppMaster.master" AutoEventWireup="false" CodeFile="Profiles.aspx.vb" Inherits="Profiles" title="My Apps" StylesheetTheme="Paper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainCopy" Runat="Server">
<div class="container" style="left: 0px; position: relative; top: 0px; height: 8%">
<h2>
Personalization Options</h2>
<p class="teaser">
<asp:Label ID="Label1" runat="server" Style="left: 1px; position: relative; top: 6px"
Text="Manufacturer Interest:" Width="142px"></asp:Label>
</p>
<div class="readmore">
<aspropDownList ID="DropDownList1" runat="server" Style="left: 33px; position: relative;
top: -22px" Width="193px">
<asp:ListItem>Oracle</asp:ListItem>
<asp:ListItem>Microsoft</asp:ListItem>
<asp:ListItem>Siebel</asp:ListItem>
<asp:ListItem>Optio</asp:ListItem>
<asp:ListItem>Primavera</asp:ListItem>
<asp:ListItem>Meridian</asp:ListItem>
<asp:ListItem>Autodesk</asp:ListItem>
</aspropDownList>
<asp:Button ID="Button1" runat="server" Style="left: -1px; position: relative; top: 48px"
Text="Save Profile" OnClick="Button1_Click" /><br />
<br />
<br />
<a href="javascript:;" title="More info"></a> </div>
</div>
</asp:Content>
Code Behind:
Partial Class Profiles
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
DropDownList1.SelectedValue = Profile.manufacturerInterest
End Sub
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Profile.manufacturerInterest = DropDownList1.SelectedValue
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
End Class
Thank you for your help.
Trevor
I'm new to asp.net. I am having trouble updating and displaying a profile property through a dropdownlist. I believe the problem has something to do with autoeventwireup but I'm not sure. If I change the selection in the dropdownlist and click Button1, the profiles database gets updated and the control shows my new selection, but when I browse to a different page and come back to this page, the dropdownlist gets set back to the default selection (the first item in the list). Why is this happening and how do I fix it?
Here is my code:
<%@ Page Language="VB" MasterPageFile="~/AppMaster.master" AutoEventWireup="false" CodeFile="Profiles.aspx.vb" Inherits="Profiles" title="My Apps" StylesheetTheme="Paper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainCopy" Runat="Server">
<div class="container" style="left: 0px; position: relative; top: 0px; height: 8%">
<h2>
Personalization Options</h2>
<p class="teaser">
<asp:Label ID="Label1" runat="server" Style="left: 1px; position: relative; top: 6px"
Text="Manufacturer Interest:" Width="142px"></asp:Label>
</p>
<div class="readmore">
<aspropDownList ID="DropDownList1" runat="server" Style="left: 33px; position: relative;
top: -22px" Width="193px">
<asp:ListItem>Oracle</asp:ListItem>
<asp:ListItem>Microsoft</asp:ListItem>
<asp:ListItem>Siebel</asp:ListItem>
<asp:ListItem>Optio</asp:ListItem>
<asp:ListItem>Primavera</asp:ListItem>
<asp:ListItem>Meridian</asp:ListItem>
<asp:ListItem>Autodesk</asp:ListItem>
</aspropDownList>
<asp:Button ID="Button1" runat="server" Style="left: -1px; position: relative; top: 48px"
Text="Save Profile" OnClick="Button1_Click" /><br />
<br />
<br />
<a href="javascript:;" title="More info"></a> </div>
</div>
</asp:Content>
Code Behind:
Partial Class Profiles
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
DropDownList1.SelectedValue = Profile.manufacturerInterest
End Sub
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Profile.manufacturerInterest = DropDownList1.SelectedValue
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
End Class
Thank you for your help.
Trevor