I'm building a wholesale order form on a website.
The current plan is to...
-get an ArrayList of DepartmentUnits
-a DepartmentUnit has various attributes like "deptId", "description" and its own ArrayList of StoreItems
-The StoreItems have attached ArrayList of various SizeOptions
-The SizeOptions have an inventory count integer along with their description
-Planning on putting an asp:Repeater on the page that has an asp:GridView in it
-Each DepartmentUnit will have its own GridView
-EachStore item will have a row in the GridView
-Each SizeOption will have a TextBox in the row (approximately 10 options)
-Each inventory count will be watermarked over the size option textbox
The question becomes how will I then collect all this information correctly once the form has been filled out? I don't like the idea of putting all this information in an update panel and then posting back each time a GridView row or worse one of the row's textboxes changes.
Any advice on putting a single save button on the page and looping through each Repeater item - and each GridViewRow - and each textbox - to get all the values entered?
Better to try collecting all the items added in a single table at the bottom of the page and updating the string with jquery each time a text box is modified?
Then just looping through the new table when saved? Not sure I know how to loop through that table though - updating if quantity is changed might be a bear too.
If it considerably simplifies the process I could just remove the Repeater aspect and put separate GridViews on separate pages.
Thanks!
I decided to have the item key be on the GridView statically and build the other columns dynamically. Then using foreach (GridViewRow gvr in gvMain) I can loop through each row and FindControl each textbox. After finding a textbox if the value has a quantity I add it to an ArrayList and keep going. Once done I'll loop through my ArrayList and adjust my shopping cart.
Related
I am using Infragistics Grid in my web application. I have checkbox inside a template field. My grid has a paging too. when I do selection of some rows and go to next page my selection is not persisting. Is there any property which we need to set?. Also I saw that there is Row Selection property but in my case I have a checkbox control inside my grid. How to maintain my selection over paging.?
There is no property which persists selection in the WebDataGrid for pages that are currently not loaded. This is so because the WebDataGrid paging is entirely performed on the server-side and the grid is rebound every time the current page index is changed. The old row objects are disposed and new row objects for the current page are created. Implementation is such for performance reasons.
In order to persist selection, you would have to do a little bit of custom implementation. Keep track of the key of your selected row in code behind, and every time the grid is rebound, check whether the key is present in the current row collection and mark the row as selected.
I'd like to get a grid with ability to add subheader (one or several rows) according to value of certain column (data source is grouped sorted by this column). Within my inherited GridView I override OnRowDataBind method: If value of considering column on current call of OnRowDataBind is not equal to previous values, then special header row is inserted before current row.
Table tbl = this.Controls[0] as Table; //this - pointer to CustomGridView
tbl.Controls.AddAt(rowIndex + add_counter + 1, NewSubHeaderRow); /*rowIndex - RowIndex of current row, add_counter - amount of already added SubHrader rows */
All works right. But problem occures on postback, when GridView restores it's state. First row and all its controls into every group (other words, first row after each dynamically added subheader row) comes without any attributes. But second row in group keeps both its own attributes and attributes of first row.
Some help will be very usefull. Maybe there is another (and right) way to add row into GridView. Then please, provide me with links to tutorials or articles.
Dynamic controls disappear on postback because on postback framework doesn't have information about such controls. It's programmer's responsibility to keep track of these dynamic controls and recreate them after postback...
Please refer to following post for re-creating dynamic controls on postback:
FAQ: Why do dynamic controls disappear on postback
Thanks for Waqas.
Here is my decision.
I override CreateChild(datasource, isBinding) and create list where put index of row, before which you should add subheader row. On SaveViewState i add this list to sealized object. On Load ViewState i load this list and if it's not null create subheader rows by saved indexes.
Maybe, there is a simpler and more natural way. But it's hidden from me securely )))
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.
I have been given a mockup that I do not know is possible to code in ASP.NET without being a real html and javascript wizard.
I want a GridView that when a row is selected, the selected row expands and below the selected row a panel of additional information is shown, which would also include another small GridView. The idea is this would all be in-line. So if the user selected row 4, then the additional information would appear below row 4 and then after the additional information the parent GridView would continue with row 5.
Ultimately I would want to do a multi-select type of set up, but first I need to figure out if this is even possible. Also, the solution must be 508 Compliant
The one solution I considered was using only one "column". Then I would put all my fields in the ItemTemplate, and my detail panel content in the EditItemTemplate and instead of selecting the row, set it to edit mode. The problem with this solution is I lose the functionality of multiple columns if I throw everything in one huge ItemTemplate.
Any and all suggestions or ideas are appreciated.
What you're describing would be best fulfilled with a ListView control. It takes a little more templating work to set up than a grid view, but you have much more control over it and you can emulate the look of a GridView. You would set your Selected Item template to contain another ListView (or GridView) thats bound to your detailed data.
I've done this using a gridview inside a ListView and using ajaxcontroltoolkit collapsible panel
Your parent list would be a listview that would have 2 table rows for each item, on the first row your parent column, on the second row use colspan and add a gridview wrapped on a collapsible panel
I have a custom gridview on rowdatabound i am adding new gridviewrows . but on postback the data in newly added row is not persists. Please help me to maintain the state of grid on postback as well...Actually i m showing group header rows and footer rows and showing some calculated values in group footer row...but on post back the values of new group rows is not persists but the grid row is ther without values.
You're adding the rows dynamically so you have to populate the grid every time the page is posted back, not just if(!this.IsPostBack).
If you're not persisting to a db every post-back and generating the grid looping through some result-set coming from your db - you might have to store info about the temporary rows in ViewState. People will be able to help on this if you expand your question.
If you're populating dynamically and the data is coming straight from some db (or even State) every post-back you might wanna disable the grid viewstate (as in that case you're sending back and forth useless stuff).