Solved

Property values

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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