Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Property values

Posted on 2006-07-20
5
Medium Priority
?
310 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 400 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

782 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