Solved

Property values

Posted on 2006-07-20
5
297 Views
Last Modified: 2010-04-16
Hi Experts,

I have two drop down lists on one page, I have a base class that exposes properties for the form values so that they can be used throughout the request.

Here are the drop down selected index changed methods:


protected void ddProducts_Changed(object sender, EventArgs e)
        {
            if (int.Parse(ddProducts.SelectedItem.Value) == 0)
            {

            }
            else
            {
                BuildCardDesignDropDown(0,int.Parse(ddProducts.SelectedItem.Value),editCardDesign.ClientId);
            }
        }

        protected void ddClients_Changed(object sender, EventArgs e)
        {
            editCardDesign.ClientId = int.Parse(ddClients.SelectedItem.Value);
        }


when i put a watch on BuildCardDesignDropDown call, the editCardDesign.ClientId is 0, but the client drop down list appears before the card drop down list and therefore sets the editCardDesign.ClientId.

I believe this is being caused by the page posting a post back when the user selects a client (drop down), but I thought that setting my exposed property would then still be available later on.
0
Comment
Question by:watherton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
topdog770 earned 100 total points
ID: 17148435
I'm not sure I understand your question completely, but if it's a matter of persisting the selection value... a session variable would do the trick

0
 
LVL 3

Expert Comment

by:BBK_
ID: 17151685
question is not well clear, cud u pls give more details....
0
 

Author Comment

by:watherton
ID: 17151895
sure...


user selects a client from the client dropdown list and sets a property of ClientId with the selected value. This property is in a class that is declared as follows:

CardDesign editCardDesign = new CardDesign.

Ok then the user has to select the Product, the BuildCardDesignDropDown method expects three params, these are used to populate another drop down list of CardDesigns.
However, when I pass editCardDesign.ClientID, which has been set by the client drop down selection, this value return 0.

Why is this?

Hope this is clear
0
 
LVL 3

Assisted Solution

by:BBK_
BBK_ earned 100 total points
ID: 17151927
I assume after selecting the Client Drop down a post back is happening, rite?
But those values you have assigned to CardDesign. But that is not accessible in next postback.
IF this is the case then you should store the instance of “CardDesign” in session. Then in the next pos back you should get the instance from the Session.

Like in

protected void ddClients_Changed(object sender, EventArgs e)
{
  editCardDesign.ClientId =       int.Parse(ddClients.SelectedItem.Value);
  Session["CardDesign"] = editCardDesign
}


protected void ddProducts_Changed(object sender, EventArgs e)
        {
            if (int.Parse(ddProducts.SelectedItem.Value) == 0)
            {

            }
            else
            {

                BuildCardDesignDropDown(0,int.Parse(ddProducts.SelectedItem.Value),((CardDesign) Session["CardDesign"]).ClientId);
            }
        }
0
 

Author Comment

by:watherton
ID: 17151939
great stuff. thanks for the reply
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question