How to choose a databindable grid control - asp.net

I recently started working with ASP.NET 3.5, having previously worked with C# and WinForms (mostly .NET 1.1) for about 6 years.
My head spins every time I need allow the user to view, add/remove or edit a list of items. This is due to the similarities, and differences, of the following controls
DataGrid
GridView
ListView
DataList
Can anyone point me in the right direction of a nice list that does a side-by-side comparison of these controls?
Which is your "favourite", or your favourite for any particular scenarios?

Short answer, with the exception of listview, they all suck ;-) Depending on your particular situation, you probably want to look into a more full featured grid by a third party, such as telerik or devexpress.
long answer, it depends on what you want to be doing.
DataGrid and DataList are mostly there for backwards compatibility. GridView and DataList are better then the older versions.
GridView is for when you want to display a grid of data. It gives you CRUD (create read update delete) operations mostly for free, and also has paging and sorting mostly for free (depending on what kind of data source you are using)
DataList is for when you want a more free form list of values.
ListView (and datapager) is our brand spanking new asp 3.5 control, and is even more free form then DataList. It lets you set up a layout template with whatever you like, and an item template which will repeat for each item in the list. You stick a container element (div/panel/placeholder) into the layout template, then tell the control which one it is, and it will repeat the item template into it for each item on the list.
You can also point a DataPager control at it, and get paging mostly for free.
Depending on what kind of site you are doing, using the built in data controls (other then repeater and listview) may end up painting you into a corner, as they have alot more overhead then are needed. If it is a small one off project, that isn't much of an issue. If its a big project where perf will be an issue, I would recommend again checking out third party controls.

Related

Recommendations for Implementing Complex ASP.NET Grid with AJAX Functionality

I'm considering going at this myself because my requirements are particular and highly customized:
The grid is bound to a
collection of complicated objects,
each of which may contain child and
grandchild objects. Depending on
data and context, the template'd
cells vary from TextBoxes to
ComboBoxes to Calendars to a
combination of controls.
TextBox cells have Google-style
auto-complete functionality. Also
each TextBox cell can expand into a
small TreeView pane that allows
hierarchy-navigating selection of a
value should auto-complete be
insufficient.
Values from other controls can be drag-and-dropped into cells.
Columns are re-sizable and re-orderable. Clicking their headers
sorts data.
All of the above is AJAX /
client-side / Web 2.0 of course.
Has anyone built anything similar from scratch? Or used an effective tool to accomplish this goal? How well would Telerik meet my specs? Is it right to have the hunch that something this specific is best done by taking a Microsoft GridView and extending it myself?
Thanks for your two cents.
If you have a SQL Server-based application, you could consider using ASP.NET Dynamic Data as a starting point. I have used it for the first time a few weeks ago and found it quire useful. It provides a lot of functionality, but you still can customise nearly everything. However, seeing your requirements you probably will have to customise a lot of things.
If you intend to use Telerik based on the specification you put forth, browse the online demos of their Ajax grid first. Most of the features are supported I think (some by integrating other Telerik controls in the grid like RadComboBox with auto-complete), for the rest you should count on your custom coding.

Telerik RadGrid: grid clientside pagination

I have a web service which returns me some data,I am massaging this data and using this as datasource for my radgrid (telerik). The datasource is quite large, and would like to paginate it. I found couple of problems when I paginate it in the server side
I have to bind the grid again for pagination, which essentially means I have to make a call to WS again to get the data. This is an expensive call for me. I would rather forgo the benefits of pagination and would display all the results in the same page, except for it would be a bit clumsy
During the postback RadGrid1.Items.Count happens to be the number of items getting paginated (25- in my case) which is expected as all the items in the datasource are not getting bound. This of course is not an issue. The real issue is that we have some checkboxes which get checked based on some business condition. We add this to our business object/DB later. So if the user has not navigated all the pages, these "checked" items do not get added as pagination limits the "Items" in the grid to those which get bound for that particular page index.
My Thoughts:
I would rather have some sort of client side pagination, where we can hide/show contents than going to the server and doing a databind every time. Though it will return all the results, the UI will not be clumsy and the grid would have "all the items" during postback
Is there a way to do it ?
If it were a regular asp.net gridView, can someone point me to a good article which would serve my purpose
Ram
PS: who else think radgrid is crazy ? (unfortunately I did not make this choice)
Recently during my project implementation (which is built with RadControls and RadGrid in particular) I found a handy example that shows how to get grid data from web service and implement paging with a single call to that web service. Check it out:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/declarativedatabinding/defaultcs.aspx
Dick
[I don't have any experience in using RadGrid as well as Telerik, so this solution may/may not work for you]
Silverlight 3 has native support for pagination, you can get more info at PagedCollectionView
BRIJ MOHAN also wrote a nice tutorial on how to leverage this class as well as other cool features like column grouping.
http://weblogs.asp.net/brijmohan/archive/2009/08/01/silverlight-3-datagrid-columns-grouping-using-pagedcollectionview.aspx

To build, or not to build a kind of Gridview control from scrach?

I want to show some results in a GridView kind of way.
But for each page I want to show 3 "inner Repeaters" showing data from 1-10,11 20 and 21-30 respectively. You can see this in the folowing image.
alt text http://img196.imageshack.us/img196/1285/examplesv.jpg
My question is, is this easier to buid with only one gridView, and several Item Templates,
OR should I buid a new user control from strach?
I'd recommend building your own user control from scratch for this. Even when used for its intended purpose (displaying table-based data), working with the GridView is like having a root canal.
In general, when it comes to non-standard UI elements (like what you're doing), you will probably end up spending much more time trying to hammer an existing control into the shape you need than you would just writing your own from the ground up.
Do you need all the functionality of a gridview, or are you just rendering and paging data? If not, then perhaps the Gridview is not the appropriate control to build from.
Also, be sure to look into the new ListView and datapager controls.
http://www.west-wind.com/WebLog/posts/127340.aspx
I'd have a close look at ExtJS's Grid. It's impressive looking and has a lot of features you need. The JS file generated may be a bit large though so maybe build your own if you're putting this on the internets.

Alternative UI control for large data lists instead of DropDownList

I am using C# and ASP.NET with version 2.0 of the .NET Framework library on this particular project. We are also using the AjaxControlToolkit. The AjaxControlToolkit should have the controls available to make a descent User Interface solution to the problem I'm facing.
I have run into this in a few projects in the last year, and used different solutions in the past. The current design of the project I just picked up, is that there is an <asp:DropDownList> control and on page load a Database call is made to get a list of values. This is then bound using DropDownList's datasource. The problem is that there is 25k items returned from the database. First thing, that's not acceptable for a user to have to scroll through tens of thousands of items. But, even more importantly, is that in every browser that it is tested on (IE 7, FF 3, Safari, and Chrome) the browser completely hangs as it is propagating the dropdownlist items.
What I'm thinking is using a Modal Popup form, which an Autocomplete Extender that allows the user to drill down to a specific company. So, in the field where they have to choose a company, they click on a "select company" icon, the modal form comes up, letting them use the autocomplete extender to select an existing company. They click "Ok" and it save the value to the field.
However, I'm an old school command line/shell/terminal guy, and my ideas of acceptable UI design might be skewed (give me a command prompt on any system, and I'm good to go). I would like the advice of those in the community here as to what they think would be an acceptable solution, or if they have faced other issues like this.
I think your idea for the autocomplete extender is the best solution. I've had this problem as well (sounds similar--a project you are taking over from somebody else). The push-back often comes from the user side. They are used to being able to select from a list of items. Unfortunately as the database grows, this becomes less and less feasible.
But when you have 0.5MB of html downloaded on the page (not including the viewstate), compromises have to be made.
Why do you think you need to create modal popup? Can't you just have the extender on your data entry page?
I had to deal with the same issue. But I ended up using a combobox with paging support and auto complete. Currently this combobox happens to be from Telerik. Its a comboBox for auto complete since you can't type into a droplist.
I agree that no user is going to want to look thru 25,000 items to find the one they want. Is there some way you can limit the data so that they drill down? Like selecting a region or type of company first and then showing the ones that match?
Multiple cascading ListBoxes, each futher refining the resultset of the previous
AJAX AutoCompleteExtender

Problems migrating databinding in VB.NET from Winforms to ASP.NET 2.0

And this was supposed to be so easy...
I have existing business and data access layers that handle the retrieval and update of the data in question. These work great with the existing Winforms application (.Net V2.0)
Now, in trying to write a new web-based UI, I'm running into all sorts of problems (last time I wrote asp.net code was in 1.1). Specifically, I can't data bind a text box to a business object. Oh, sure there's the ObjectDataSource but that wants to know how to do CRUD operations on the data.
What I'm looking for is something that acts like the classic binding objects so that, in my code, it's as simple as retrieving the object and doing a a refresh. The data component like FormView and DetailsView are so generic-looking that it's ridiculous. The existing application would have tabbed dialogs, text boxes grouped by panels, etc.
On top of that, I have a directive to use master pages and unless one control causes it, I can't seem to get the content section to expand. I can't just put a text box below the bottom of Content1 and have it re-size the content section - which gives me the same results as an earlier question I posted when the footer wasn't being pushed down - relative position solved that but doesn't seem to solve it with placing small text boxes in the area.
What I want is fairly simple. Something like:
bindingobject.datasource = businessdataobject
bindingobject.refresh
...and have the text boxes refresh with the new values. Likewise to have businessdataobject properties updated as the user enters new data.
I was able to do this with the GridView (grdRequests.DataSource = lstRequests) by making a list of asp:BoundField tags inside the <Columns> collection of the GridView.
Am I tilting at windmills here?
Why don't you give the Patterns and Practices (1) ObjectContainerDataSource a try? It's part of the Web Client Software Factory which is available (2) here.
I've used it a few times, it gives you the ODS-style design experience (design time binding) but full control over how you provide the data source. You just implement the events you are interested in (e.g. Selecting event). It also has server side paging and sorting support so it's quite useful for GridViews.
It might not be flexible enough for what you aretrying to achieve, but it's probably worth checking out if only as a PoC.
[ (1) http://www.codeplex.com/websf/Wiki/View.aspx?title=Object%20Container%20DataSource ]
[ (2) http://www.codeplex.com/websf ]

Resources