Solved

Property values

Posted on 2006-07-20
5
283 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
  • 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Media.Imaging 1 18
Question! 4 36
How to call weather service by using asmx? 4 29
Need to start a web service from Visual Studio 2015 Pro 2 21
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…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now