[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Formview CurrentMode changes unexpectedly

Asked by allanmark in Programming for ASP.NET, Microsoft Visual C#.Net, C# Programming Language

Tags: FormView, object data source, ASP.Net

Greetings all

I have a page that conatins a listbox (holds people names) and two formviews (each linked to an ObjectDataSource) - one  that holds the selected person's personal details and one that holds their address details. As the user scrolls up/down the listbox, the corresponding details are displayed  -- no problem with that.

When the user clicks the Insert button on the personal details (ie they want to create a new person, the personal details formview displays the InsertTemplate without any problem. The address formview needs to display the EmptyTemplate, as the select should have no data.

In the person formview's ModeChanged method (see attached), I have confirmed that its CurrentMode = Insert. I then I call the Select method of the address ODS. Control then passes to the OnSelecting method of the address ODS. Here I check the CurrentMode of the person formview, before setting the parameter to zero (if the person formview CurrentMode = Insert) - PROBLEM  -- the CurrentMode is ReadOnly -- so the wrong code is executed. When execution retuirns to the person formview's ModeChanged method, the CurrentMode is back to Insert.

As an experiment I created a priuvate variable, at the class level and then set it's value to the CurrentMode of the person fromview , in the person formview's ModeCHanged method. Then, in the addres ODS's Selecting method, I check that value and it is null -- almost as if it's doing another postback - yet, I have a break in the Page_Load method and it isn;t hitting that.


Any thoughts on what I'm missing?

In advance, thanks!!

   allanmark

CODE BEHIND:
 
 
 protected void addressODS_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        string beforeSelect = fvSpousal.CurrentMode.ToString();     // equals "ReadOnly"
        if (fvSpousal.CurrentMode == FormViewMode.Insert)
        {
            e.InputParameters["CoupleId"] = 0;
        }
        else
        {
Greetings all
 
I have a page that conatins a listbox (holds people names) and two formviews (each linked to an ObjectDataSource) - one  that holds the selected person's personal details and one that holds their address details. As the user scrolls up/down the listbox, the corresponding details are displayed  -- no problem with that.
 
When the user clicks the Insert button on the personal details (ie they want to create a new person, the personal details formview displays the InsertTemplate without any problem. The address formview needs to display the EmptyTemplate, as the select should have no data.
 
In the person formview's ModeChanged method (see attached), I have confirmed that its CurrentMode = Insert. I then I call the Select method of the address ODS. Control then passes to the OnSelecting method of the address ODS. Here I check the CurrentMode of the person formview, before setting the parameter to zero (if the person formview CurrentMode = Insert) - PROBLEM  -- the CurrentMode is ReadOnly -- so the wrong code is executed. When execution retuirns to the person formview's ModeChanged method, the CurrentMode is back to Insert.
 
Any thoughts on what I'm missing?
 
In advance, thanks!!
 
   allanmark
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
CODE BEHIND:
 
 protected void addressODS_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        string beforeSelect = fvSpousal.CurrentMode.ToString();     // equals "ReadOnly"
        if (fvSpousal.CurrentMode == FormViewMode.Insert)
        {
            e.InputParameters["CoupleId"] = 0;
        }
        else
        {
       ......................
      ...................................
 
 protected void FvSpousalODS_ModeChanged(Object sender, EventArgs e)
    {
        string before = fvSpousal.CurrentMode.ToString();    // equals "Insert"
        addressODS.Select();
        string after = fvSpousal.CurrentMode.ToString();    // equals "Insert"
 
    }
 
 
 
SOURCE:
 
        <asp:FormView  ID="fvSpousal" runat="server" DefaultMode="ReadOnly" OnDataBound="fvSpousal_DataBound" DataSourceID="spousalODS"
                EnableViewState="true" DataKeyNames="C_Id,SP1_Id,SP2_Id" CssClass="smallFontSize" OnModeChanged="FvSpousalODS_ModeChanged" 
                OnItemCommand="fvSpousal_ItemCommand" OnItemUpdating="FvSpousal_ItemUpdating"  OnItemInserting="FvSpousal_ItemInserting">  
   ................................
   ......................
 
<asp:FormView  ID="fvAddress" runat="server" DefaultMode="ReadOnly" DataSourceID="addressODS"
                EnableViewState="true" DataKeyNames="R_Id" CssClass="smallFontSize"  OnItemUpdating="FvAddress_ItemUpdating"
                OnItemCommand="fvAddress_ItemCommand" OnItemInserting="FvAddress_ItemInserting"  >  
   ................................
   ......................
 
 
        <asp:ObjectDataSource ID="spousalODS" runat="Server" TypeName="BusinessLogic.Business" DataObjectTypeName="DataTransferObjects.SpouseODS_DO"
            SelectMethod="GetCouple" UpdateMethod="SpousalODS_Update"  InsertMethod="SpousalODS_Insert" DeleteMethod="SpousalODS_Delete"
            OnSelected="spousalODS_Selected" OnSelecting="spousalODS_Selecting" OnUpdated="SpousalODS_Updated" OnInserted="SpousalODS_Inserted"
             OnDeleted="SpousalODS_Deleted" OldValuesParameterFormatString="{0}"  >
   ................................
   ......................
 
    <asp:ObjectDataSource ID="addressODS" runat="Server" SelectMethod="GetResidential" TypeName="BusinessLogic.Business"
            DataObjectTypeName="DataTransferObjects.AddressODS_DO" InsertMethod="AddressODS_Insert" 
            OnInserting="AddressODS_Inserting"  OnInserted="AddressODS_Inserted" UpdateMethod="AddressODS_Update" OnUpdated="AddressODS_Updated" 
            OnSelecting="addressODS_Selecting" >
   ................................
   ......................
[+][-]05/26/09 11:05 PM, ID: 24480205Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/26/09 11:34 PM, ID: 24480322Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/27/09 12:54 AM, ID: 24480675Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/27/09 03:05 AM, ID: 24481326Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/27/09 07:41 AM, ID: 24483572Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, Microsoft Visual C#.Net, C# Programming Language
Tags: FormView, object data source, ASP.Net
Sign Up Now!
Solution Provided By: allanmark
Participating Experts: 1
Solution Grade: A
 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625