For one of my projects I need to allow the user to select some products out of a table.
This table will be paged (+2k records in DB).
So the user needs to be able to select items on different pages without losing them.
I was thinking about using 2 tables. One table to select items from and another table(also with paging) where the selected items will be displayed.
But I have no idea how to persist the selected items without using Sessions...
If anybody has a better idea please share it.
Edit:
It is possible(won't happen that much) to select all products (+2k records).
I don't know how mvc will behave if you have 2k hidden fields.
Also lets say i use hidden fields and have the following in my viewmodel
public List<int> SelectedIds {get;set;}
I can then use hidden fields with "SelectedIds[i]" as name(replacing i by an integer).
But the user can also deselect the items again.
And I don't think the binding will work when you skip numbers.
ex: 2 hidden field with these names "SelectedIds[0]" && "SelectedIds[2]"
This is something I'll have to test when i am home...
Related
I have looked-up custom paging with gridviews in ASP.NET, but it seemed to work only for displaying exact same rows from the database to the web page.
In my case, I currently use default gridview paging to select all rows from the database, then process that data in the code behind of my aspx page, and then show custom rows based on that processed data in my gridview.
My question is: I want to know how to select a certain amount of rows from the database that will reflect just enough "custom" rows for 1 page in my gridview on the web page.
Note: I process the data on the front-end and group them in custom rows based on a common, same FKID value.
Would really appreciate the help,
Regards.
Does each FKID-value have the same amount of rows in your table? I assume this isn't the case.
I think your options are the following:
You could leave your logic as-is. If the performance isn't too bad, I think this is the easiest solution.
Create a view at database-level. This view should then directly provide records as you need them as a row in your GridView. This puts the paging-logic at the database-level, and is performance-wise the fastest option I think.
Do the same as option 2, but then at your application level. That could work this way: Construct a select query that gives you the count of distinct FKID values, and a query that can give you a list of FKID values based on a 'startindex' and 'number of rows'. For each FKID returned, fire another query fetching the corresponding rows. Apply your logic, and return the page of rows to your GridView.
I have two tables in my database namely Employees and TimeLogs. Basically I want to create a Daily time record using rdlc. So, what I wanted is to display each employees' time logs.
Like:
I tried to list within a list but it doesn't work. Tried subreport within a table, but I get errors. Tried list within a subreport that's within a list.
Can some one have a much better way of doing it?
In Tablix you can add Groups to organize your data.
In your case you can group by employee and display times as details.
I have currently implemented a drop-down which displays all the products name from database. On selection of product name from drop down my edit product form will get populated and user can update selected record successfully.
Now my problem is that i have 5000 products in my database.In this case its very difficult for end user to select particular product in drop-down and also populating drop down with large number of records server side takes more time.
What approach should i use to make selection user friendly.Any ideas or help is greatly appreciated
Thanks!!!!
You should use an editable combo box with auto complete feature and load the data depending on user input. Refer this: http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/ComboBox/ComboBox.aspx
This way you dont need to worry about the amount of data, it gets filtered as the user inputs some string.
From time to time, I need to create an input control which allows multiple rows of input, the type of input and number of columns could be different in each case but typically it would be represent a database table being edited, so it should also be possible to store an id value within each row. It should also be possible for the user to add new rows to the input if they have more data to input.
I have tried a couple of approaches to this but they are all very long winded for what seems like such an obvious and common scenario. I'm thinking that there must be a simple way to do this that I have missed.
The way that I usually solve this is by using a list view, enter all of the input controls required within the item template and use a html table for formatting, with each item being a row of the table. If there is existing data to be edited, I would load the data from the database, add a blank object to the results and bind it to the list view. If there is no existing data, I would create a collection with a blank record in it and bind it to the list view. I add a button for adding a new row. When clicked, this button retrieves all of the existing data from the list view by iterating all of the listview items and populating the data into a collection, which I would then add a blank object to and rebind the listview with the results. When saving, I would retrieve the results by iterating the listview items again and using a hidden field within each row to store the record id. This would determine whether a new record was added or an existing record was edited.
This approach works for me but I'm sure there must be simpler ways to achieve this. Looking forward to seeing how other people solve this.
For web forms, use a GridView. You can set its properties to allow editing, deleting, new rows, sorting, and paging.
Check out the MSDN example here that shows how to use it. If you bind a datasource to it, it will figure out the columns and adjust dynamically then, or you can predefine the columns you want for more customability.
You are talking about bulk insert/update. You could use XML insertion/updation for this purpose. Get all the data to a DataSet ds variable. Then use ds.GetXml() method to convert the dataset to XML string. Pass this to an XML parameter into SQL server which has the datatype 'XML'
INSERT INTO YOURTABLE
SELECT
V.VOI.value('(.)[1]', 'int')
FROM
#Input.nodes('/DATASETNAME/DATATABLENAME/') V(VOI)
Use this link to learn more
You need dynamic table with Add, View,Edit and delete operations on each data.
I would suggest using DataTable Jquery component. there are tons of examples on Data operations, and you can plug this with any Server technology including ASP.net
http://editor.datatables.net/
I am creating a staff rota system in visual studio and would like to populate some textboxes with the staff names from a database to ensure the user does not miss any staff for the rota. Obviously staff will come and go therefore the number of textboxes may need to change.
For instance one week there may be 5 staff members to enter into the rota, but if a staff member leaves the company then the number of textboxes will have to automatically change and be populated with the names from the table after the staff member is deleted from the database.
For the end result I plan on having a list of textboxes populated with the names of existing staff members from the table. This will then allow the user to select their shift times and lunch hours etc.
Any advice or recommendations would be greatly appreciated.
Instead of textboxes...
Use Radio buttons if ONLY one can be selected from the list
Use Checkboxes if MORE than one can be selected from the list
Only use a textbox if you wish to EDIT the names (data)
#Thousand Thanks for the suggestion of using asp.net repeater control.
I did not wish to edit the information I was extracting so I have created a template which extracts the data into labels. Thank you and apologies as this question is in the negative.