473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

need to update and display profile property through dropdownlist

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>
&nbsp;
</p>
<div class="readmore">
<asp:DropDownList 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>
</asp:DropDownList>
<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>&nbsp;</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
Jan 5 '06 #1
1 1858
I didn't realize that page_load was getting fired before button_click, I added a check for IsPostBack and that solved the problem.

Thanks.
"Trevor Bezotte" <me******@newsgroups.nospam> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl...
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>
&nbsp;
</p>
<div class="readmore">
<asp:DropDownList 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>
</asp:DropDownList>
<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>&nbsp;</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
Jan 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phl | last post by:
hi, does any know why my javascript dropdownlist in my user control will only appear if I have my code as follows: // create an instance of the user control Control UCAdminDDMenu =...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
0
by: Miguel Dias Moura | last post by:
Hello, I am saving a complex type in Asp.Net 2.0 profile. I am using an SQL 2005 database as a profile provider. I have been consulting MSDN as help to create my class. (Please, see my code...
4
by: dsimmons | last post by:
On my website http://seasidequilters.blogspot.com/ I'm having a problem that someone thinks might be associated with Firefox browsers. I'm hoping to find someone in this forum that might be...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
0
by: Mike P | last post by:
Where exactly are the updateparameters of a gridview picked up from? I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates. Yet this...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
1
by: shapper | last post by:
Hello, I have a profile with multiple profile properties in my Web.Config: <add allowAnonymous="false" name="Contact" type="Contact" serializeAs="Binary"/> <add allowAnonymous="false"...
9
by: Kirk | last post by:
I have successfully, implemented a custom Membership Provider to a SQL 2000 table, however, I am having problems doing the same with a Profile Provider. As I understand it, the steps for both of...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.