I'm designing an ASP.NET screen which configures what screens are relevant for a particular type of record. For example a car record will have access to the Ford and Ferrari pages. I'm displaying a listbox on the left with all available items, and a listbox on the right with currently selected items. Two arrow icons allow you to move items from left listbox to right listbox and vice versa.
I'm trying to figure out a good way of storing the selected access. Easiest would be to delete all the currently selected items and reinsert the items from the Selected Items listbox. But the changes need to be audited more accurately so need individual inserts and deletes. Should I store the original items in a hidden field and then try to compare the final selected items with the original? Should the work be done in the Presentation layer, within an object or in a stored procedure?
Thanks for any guidance,
Dean
I would not do it on the presentation layer, send the new list to your business layer. In there retrieve the current list and do a compare with the new list. The do your inserts and deletes based on that.
If you want the selection to be persistant you should store them in DataLayer.
Business Layer : Car Entity and Cars Collection
At server side you can create a collection of items that contains all (selected/ not selected) items.
A car entity item requires its name, id and selected info. store this collection in session when user enter the page and check it whenever you want.
Here is a Car Item :
CarItem
Id
Name
IsSelected
Related
How can i populate drop down lists in mvc5 such that each list is dependent on the previous drop down list?
Example:
Database stores information on cars first field drop down list should display all car manufacturers, depending on my selection the second field drop down list should only display data of car models for the brand i have selected.
You should use js for dropdown 'change' event. Then at least two options are possible.
Ajax request for next drop down values (different libs like select2 could handle that scenario out of the box) or form posting to the action, which will render it back with the next dropdown values provided.
I have a local database, which holds records for cars, it has fields ID(ai, primary), plateNumber, Comments, ect..
Also I have a form with ListBox, button "Checked", and many text fields.
I am using winforms, and every time I run the application, constructor retrieves all the records from the db which have the bool field named "checked" == null, and displays the carnumbers in the Listview. When a specific plateNumber in that listBox is clicked, the other column data for the selected carPlate should appear in the textfields, but the
Problem is that there might be more records with the same plateNumber where "Checked" == null(true otherwise).
Question: how to keep the information about the specific plate number "behind the scenes" and when person clicks to select the platenumber from the listBox, it displays the data about the current(by id) platenumber in the form. Note that, if person clicks a "Checked" button on the form, it stores "TRUE" in the DB "checked" field and removes the specific carPlate from the listBox, and the next time application is launched it won't display that specific ID. In web I use hidden fields with javascript to achieve this, in C# I'm not aware how you keep information like that, I'm leaning towards arrays?
Thanks.
ListViews are populated with ListViewItems. The ListViewItem class has a Tag property, where you can store anything you want. Your "hidden" or "behind the scenes" data can be stored there.
I have a repeater with an ItemTemplate contains a CheckBox, TextBox
My repeater represents a check list plus a TextBox to put a comment to each item I select from the list.
Now, I've a page for editing an existing shopping cart in my database and it uses this repeater to enable the user to update his list. So I need to update the List with the previous selected values from the database. I can't think of a simple logic or way to access only the repeater's items that are on the previous list ...I'm thinking about trying to access each item that's in my database only instead of looping and looping.
I know It's really confusing so I'll just put it in a more illustrative way:
Database View
Items
=======================
ID Name
--- -----
1 Banana
2 Apple
3 Strawberry
4 Orange
ShopCart_Items
========================================
ItemID ItemName CartID Value
------- --------- ------- ------
2 Apple 1 1
4 Orange 1 2
2 Apple 2 2
PageView
First the repeater is populated with all the items that I have in my 'Items' table and no boxes check or anything.
Then I choose a specific cart (say cartId = 1) to edit, and here's what I'm really confused on how to do:
Now the repeater will have like 15-20 items, so I need to access just the items that the user choose on the current cart (cartId = 1) that the user want to edit, so he could know what did he choose and start choose new values, check/uncheck CheckBoxes, etc.
I'm sorry for all this long question, but I'm really confused should/can I access each item directly or what logic do you advice me to use ? ..Thanks =)
I believe that you have mix two different entities in a one repeater - an orders and order items.
In my opinion the better approach is to place two repeaters onto the page: the first one for displaying orders and the second one for displaying order items for the selected order. This way you may use simple SqlDataSource controls for both repeaters and add a ControlParameter to the datasource used for retrieving order items depending on current order selection in the first repeater.
I am loading elements (a row) from a database in a list. Which technique should I use to update the list when a new entry is added in that table ( SQL database) so that the lists updates and if I have selected an element from the list it won`t get deselected (like Outlook when new mails are received and you have a mail selected ).
If your dealing with simple database transactions, I would recommend a foray into the BindingSource Component. The BindingSource component can take care of creating, reading, updating and deleting things so you don't have to.
I assume your rows have a unique identifier. You can store this Id before you add the new row, and after it's added you can search the list with the stored Id to re-select that row.
(Actually it would be wiser to store the row handle and re-selecting it directly with the handle. But it wouldn't work if your grid creates new row objects to display the updated list. Since I don't know how you bind your data, I cannot say this would work for sure.)
I have a simple app I am messing around with its a basic Master/Details layout.
The details panel is actually a tab panel and on one of the tab panels it has a GridView. Within that grid view it shows the "current" in database information with all cells as read only.
alt text http://lh4.ggpht.com/_JU1W2P96pD4/TAeonNNYXgI/AAAAAAAAAq0/Y_-Kse7VObE/ExampleA.jpg
I then have an add button that inserts a row into the GriView and allows the user to enter some information. The first item in my GridView is a DropDownList, which is populated from an ObjectDataSource. This drop down is basically my unique index and there can only be one selected value per GridView.
alt text http://lh3.ggpht.com/_JU1W2P96pD4/TAeonIF3DdI/AAAAAAAAAq4/JhfOTsHgsf8/ExampleWithDropDown.png
What is the best way to remove the values from the list that are already in the GridView? Do I just need to remove the data source and add a OnDataBinding method that iterates through the grid view and generates a valid list of values?
I can't use a service method because if the user adds two rows they would have the option to insert duplicates description types.
Just want to make sure there is not a better way to do this.
Keep the object datasource, which I am assuming is an IEnumerable object, in a Session variable. When someone selects a certain value remove that value from the list in the session variable. Whenever they activate the form where the drop down list is displayed simply rebind the control to the list in the session variable. It will be easier than looping through the grid every time the user adds an entry.