Is the ASP.net GridView control a clever design? - asp.net

I have been using gridview since a long time. I have a "cant live with you and cant live without you" relationship with it.
The idea of Edits, inserts and deletes from within the grid is great but having to do something like
var sometext = ((TextBox)editRow.FindControl("tbSomeText")).Text;
just seems very un-clever to me. Has anyone comeup with a solution or knows (resource) where you perform CRUD operations + paging and sorting from within the grid and dont have to write ugly code (like above). I am not looking for solutions using DataSource objects since I am not its biggest fan. I will be happy if someone can tell me how to live without GridView in asp.net.
I understand there are AJAX implementations but I am looking for something completely serverside.

I always use repeater control instead of others. Because i feel free with it. I build up the html by myself and can do a lot of thing like paging sorting. But of course you need more effort for the repeater for these kind of functionality.
For CRUD operations, i use jQuery thickbox (modal pop up and iframe).
My choice is Repeater

If you are trying to make a basic CRUD website, have a look at ASP.NET 3.5 Dynamic Data which is a great website to add as a pure data access website with CRUD ability. However, its extremely customizable.
Gridview has its advantages and I used to love it in the .Net 2.0 times about two/three years ago. However, since then there are much better .Net 3.5 controls (like ListView) that give you a better ability to customize content. I'd also have a look at many third party grid tools from (Telerik, Infragistics, ComponentArt, ComponentOne, DevExpress) that have a lot more capability than the inbuilt gridview control.

I despise it, every time I've used it or seen another developer use it, they almost always end up going with something else. I've never once heard any developer I've worked with say "I love GridView".

You can hook up the GridView and DetailsView and use basic SQL scripting or complex business objects along with DetailsView.
I have found DetailsView to be very useful.

Related

Ajax enabled sorting and paging on grid in ASP.NET 3.5

Is there any good solution for ajax enabled Grid with pageing and sorting which only brings the required data from database? I mean it should only bring the data from the database which is to be displayed on the particular page number of the grid.
I looked at this. It looks good. But I just thought if anyone has created something better using Google's or Yahoo's javascript library or using any good features of asp.net 3.5.
I'm replying my own question.
I found Ajax Data Controls as updated version of what I had specified in my question. Still I will not mark it as answer and will wait for better answer.
If you are using a datasource control (SqlDataSource, LinqDataSource etc) this would be done automatically (retrieving only the current page of data). To make paging and sorting ajax-enabled wrap the grid inside an UpdatePanel control.
I used devexpress grid. It has sorting, grouping and paging. It is not perfect one but looks nice and easy to use.

asp.net repeaters. To use or not to use

We are currently using a repeater to display input fields, drop downs, check boxes, and calendar items on each row. The desired functionality is to allow the user to add up to 10(this could potentially change by web config) items (each row).
Is it appropriate to list these out in a repeater or am I going about this the wrong way? What should I be using? Is there something lighter?
asp.net repeaters. To use or not to use
USE!
A repeater is crazy lightweight and perfect for this. Use it all over the place!
Slightly more in-depth answer:
If you are having some performance problems that are causing you to rethink your code, start by profiling. It will shed light on where the real problems are right away, and I guarantee they won't be from using a repeater. The amount of time your application spends in repeater code is almost certainly not even worth measuring.
If you're not having performance problems, why are you asking? :) Go build something or have a coffee and leave well enough alone. Don't optimize until it's clear you need optimization.
Repeater is about as light weight as it gets. If you have a sound code base that supports iteratively showing fields with a Repeater, then that's basically as good as it gets.
a Repeater is about the lightest thing you can use; it only displays what you tell it to. I'd say it's quite acceptable.
ASP.NET's Repeater control is the lightest data control, if you want to get rid of it and using ASP.NET v 3.5 then I would recommend you to use Listview control instead.
Hope this works!

Are DetailsView /FormView enough rich for Edit and Insert?

I'm wondering are DetailsView/FormView and ObjectDataSource have enough capability for Inserting/Editing your records or not ?
Or better ask you Do you prefer use them or make your form by your own ?
Because some times it's not easy to use them for complicated task , On the other hand when you have a lot of fields , that's over killing make your form by your own.
No doubt you can use asp.net detailsview and formsview to edit, insert, display data. This makes it easier and faster to play around your data, if you are handy with it. Otherwise you may stumble with some typical odds, of which almost all are answered and you can find them over Internet. Conclusion: Once you get with formsview, detailsview they will be your favourite tools! That is what Microsoft wants of developers.
Still there are some points to remember: if you have forms with lots of controls and you need them interact with each other, you need to consider playing around the straight ways of formview, detailsview. In such case, you would feel very easy if you had created your own UI with necessary controls.
Yes, they do. Each of these has an insert/edit template. You can make them work, and they work fine. Have used them in my own applications. Complicated tasks, formview should be able to handle because you have full control over the UI and layout.
If you have a large form, detailsview allows you to specify fields and allows the control to do the work (you simply specify the data and detailsview handles the form), but of course with a custom UI the formview is the way to go, and yes it can be tedious to have to create large forms... but it's something we developers must do, either find or create a form builder control or create the UI markup ourselves.

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.

ASP.NET Repeater Paging/Sorting

So what's the real story on how to do this. All of the examples I find use Default Paging (HOW does anybody find that acceptable???) but I want to use custom paging. I can't use a GridView because I need more flexibility. The examples I see all use the PagedDataSource class but I can't find one that uses Custom Paging. Am I doomed to have to roll my own paging/sorting solution to avoid the bloatware of the other build-in methods?
A simple repeater used for paging where a few page numbers are rendered horizontally is pretty easy to code up and re-use.
I think most people who need this much custom work will reach for a third-party control toolkit, like Telerik, DevExpress, Infragistics, or ComponentOne.
If you want to do it once you'll probably want to do it again, and therefore it's worthwhile to have a quality, re-usable, generic, tested solution available.

Resources