The Listview control is a replacement to the GridView control.
It might be better … tho I just spent a whole day on a task that would otherwise have taken less than an hour using a gridview. My problem is I ran into a stupid bug which apparently microsoft considers a feature. You can put a text box into an InsertTemplate, but you need special code to put a combo box in the InsertTemplate. I just spend another (few) hour(s) on this … so let me elaborate … The bind method is not supported on a dropdownlist control in the insertitemtemplate. (9/2020 - actually it is, maybe it came later but I ended up using that feature all the time) SO instead you put some code on the ItemInserting method of the list view instead. An example has been provided in the webpage and code behind links below.
There’s one big difference between the GridView and the ListView … the ListView has an InsertItemTemplate will still show even when there is no data to be displayed. This is good because in a lot of my solutions I have attempted add logic in the footer area which only worked when there was data to display. I’d have a redundant set of code in the emptydatatemplate to display when there is nothing to display.
Basic Stuff - Samples coming
ASP.Net - ListView - webpage
ASP.Net - ListView - webpage codebehind
ASP.Net - ListView - business object
Advanced Stuff - Samples coming
- Add coloring to every other row. It makes the table easier to read.
- Add a buttonwhich opens a popup window.
- Add a checkbox to control a bit field.
- add a dropdown list to the InsertItemTemplate.
ASP.Net - ListView - Delete rows on a nonbound ListView control
ASP.Net - ListView - Delete Button - Add a warning
ASP.Net - ListView - Finding controls
ASP.Net - ListView - Footer Totals
ASP.Net - ListView - Formatting Columns
ASP.Net - ListView - Formatting Columns - Control Properties vs ListView events
ASP.Net - ListView - Highlight a row as you hover over grid
ASP.Net - ListView - Highlight a cell based on a value in a previous record
ASP.Net - ListView - Highlight a cell based on other values in the record
ASP.Net - ListView - Nested Listviews
ASP.Net - ListView - Validator controls in Insert Template
ASP.Net - ListView - Javascript in Insert Template
ASP.Net - ListView - Javascript in Edit Template
ASP.Net - ListView - JQuery
ASP.Net - ListView - Default Values inside Insert Template
ASP.Net - ListView - limiting records based on another listview
Events
ASP.Net - ListView - PreRender
ASP.Net - ListView - ItemDataBound
ASP.Net - ListView - ItemEditing
ASP.Net - ListView - ItemInserting
ASP.Net - ListView - SelectedIndexChanged
3 Click Bug.
Once in a while I’ll add a feature to my listview - for example a sort header link, or maybe a checkbox on the bottom of the form. My listview will be bound to an objectdataview. When I activate the feature - the databind on the listview is activated and a the … the … feature isn’t activated. It seems that it takes about 3 clicks to get that feature to work reliably.
To fix this - I think if you put code into events to move values into the SelectParameters of the ObjectDataSOurce (maybe in the ListViews Selecting event, or the ObjectDataSource’s Selecting event - it’s too late) I put the code within the function that triggered the event.