Copy selected row from one ListView to another


Author
Message
Doron Farber
Doron Farber
StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)
Group: Forum Members
Posts: 92, Visits: 612
Hi Trent,

I have Wizard which help the user to select different products. In the first page the user can select the main product and in the second page I have a ListView to show some sub products and user can select any product via a check box. In the 3rd page I need to show only the selected items from the 1st and 2nd page into another ListView which is basically a copy from the second page. For the 3rd page I created another instant as ProductsMGRItemsBO_Totals which is basically the same instant from the 2nd page named: ProductsMGRItemsBO1. At the end I need to save the Product_FK into the Items table.
In order to show all products that were selected in the 3rd page I did as follows:


Dim loTempBO As New HFALib.ProductsMGRItemsBO
Dim RowIndex As Integer = 0
Dim ProductColumn As Integer = 1

For i = 0 To Me.lvSubProducts.CheckedItems.Count - 1

    RowIndex = Me.lvSubProducts.CheckedItems.Item(i).Index
    Dim RecordPK As Integer = Me.lvSubProducts.Items(RowIndex).Tag
    loTempBO.FillByPrimaryKey(RecordPK)

    If loTempBO.Count = 1 Then
        Me.ProductsMGRItemsBO_Totals.CopyDataFrom(loTempBO,MicroFour.StrataFrame.Business.BusinessCloneDataType.AppendDataToTableFromCompleteTable)     

    End If
Next
loTempBO.Dispose()



I need you to tell me If by creating another temp BO like loTempBO so I can grab the selected record by its primary key from the second page, and then copy that into the ListView in the 3rd page is correct. Is there a better way using SF somewhere that I missed. Otherwise it works just fine, just looking for a more efficient way if any. Of couse there is more code into it but I tried to show you the specific code only.

Thanks,

Doron

 


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, in the code above you could have just used the Using operating instead of creating a variable.  Also, you should really turn Option Strict on so that you at least get a warning when trying to pass an object into an Integer, but better yet, an error (by default when Option Strict is on).  First, it will be faster since it will not have to automaticaly evaluate the types, secondly, it will prevent weak typing.  In regards to your code, I would have probably used a generic dictionary so that I have a central object that is used through all of the pages (which may hold a BO within it) but this way it just reduces code.  but your code will work, and if you have it working, then I would leave it alone aside from changing the variables into the using statement:

Using bo As New HFALib.ProductsMGRItemsBO()
    bo.FillbyPrimaryKey(...)
End Using

Doron Farber
Doron Farber
StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)
Group: Forum Members
Posts: 92, Visits: 612
Hi Trent,

Thanks for your reply.

I would have probably used a generic dictionary so that I have a central object that is used through all of the pages (which may hold a BO within it) but this way it just reduces code.

Can you elaborate a little more of the above. Since I have some redundancy in some objects. For Instant in 3 BOs for now I created the same 3 custom properties etc...

Regards,

Doron

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, I was going to, but it was going to turn into a disertation.  We will actually cover this during the class, so if you can wait 7 days, we can go over this while you are here and it will be far easier to explain.
Doron Farber
Doron Farber
StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)
Group: Forum Members
Posts: 92, Visits: 612
Yes I can wait Trent, no big deal.

Thanks,

Doron

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search