adding row to listview raises exception


Author
Message
Ian Hammond
Ian Hammond
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 277
In this particular instance I am using a listview control to display user names that can access my application. There are 2 custom fields whose content is fetched from another table. I have the listview bound to a business object which reads my usernamesBO. Each user has an entry in a userprofiles table which contains a boolean flag saying if they are logged into the application and the name of the computer they are using.

My listview displays the username, description, Computer Name, Logged In

There is a toolbar with Save Cancel Add Edit Delete

When the user click Add or Edit a child form is displayed allowing to make changes to the user profile. The BO is passed as an argument to the child form. If the user Add's a new profile, I execute a BO.NewRow() followed by assigning data to the fields. The ComputerName and LoggedIn are initialised to default values. The form is disposed an the user is returned to the parent form which excutes a listView.Requery(). Here, I am trying to display the new row.

 The Requery causes the following event to be invoked:



// Populate computer name and logged-in status

private void listViewUserNames_RowPopulating(MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs e)

{

    HLSUserNamesBO loBO= (HLSUserNamesBO)e.BusinessObject;

    if (this.hlsUserProfilesBO1.Seek("userId = " + loBO.userId.ToString()))

    {

        e.Values[2].DisplayValue =
this.hlsUserProfilesBO1.computerName;

        e.Values[3].DisplayValue = (
Boolean)this.hlsUserProfilesBO1.loggedIn ? Global.RetrieveTextValue("Text_Yes") :            Global.RetrieveTextValue("Text_No");

    }

    else

    {

        e.Values[2].DisplayValue =
"";

        e.Values[3].DisplayValue =
Global.RetrieveTextValue("Text_No");

    }

}



This code works fine when the form is initially loaded but when I return from the Add command, the section LoggedIn section causes the exception to be raised. On load the first Id =1 and this loads ok, the second record load ok. When I return from Add the first Id =1 and it fails.

I'm not sure why this is.

Can anyone priovide an explanation or solution?

Many thanks
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ian Hammond - 13 Years Ago
Trent L. Taylor - 13 Years Ago
Ian Hammond - 13 Years Ago
Trent L. Taylor - 13 Years Ago
Ian Hammond - 13 Years Ago
                         Can you shoot me a screentshot of your PopulationDataSourceSettings...
Trent L. Taylor - 13 Years Ago
                             Hi Trent, Please find attachment, as requested. Regards
Ian Hammond - 13 Years Ago
                                 [quote] I had already traced the code. What I found on initial load...
Trent L. Taylor - 13 Years Ago
                                     Hi Trent, You are right, the fields are not initialised, although in...
Ian Hammond - 13 Years Ago
                                         Well, it depends. By default a BO will initialize all of the fields...
Trent L. Taylor - 13 Years Ago
                                             [quote][b]Trent L. Taylor (3/14/2011)[/b][hr]...But the best place to...
Edhy Rijo - 13 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search