Why not we use Repeater Control instead of Gridview Control? - asp.net

I know GridView control comes with lot of built in functionality, which we can achieve from repeater control. GridView control has performance issues. Why don't we use repeater?
You will be thinking why this question, if you can achieve the functionality and performance using repeater use it, but I want to understand why and when we should use repeater and GridView. Can anybody explain me how and when?

GridView supports a tablular style of layout. So works nicely for displaying data that would fit into a table. e.g. report style data
Repeater control is good for a more free style layout. Say for displaying products on an ecommerce website or for displaying entries on a forum or blog.

Like you said, the Repeater can perform certain aspects of the GridView. In this case, you'd want to use a Repeater. However, there are differences between the controls which cannot easily be substituted (or, necessarily, worth the time to implement). You can see a table of differences here. Knowing these differences can make it easier to decide what control to use depending on your needs.
(From Link)
The GridView : it supports paging but
it doesn't provide a flexible layout ,
since its mainly used to display the
data in a table based layout.And If we
looked at data inserting , the
Gridview doesn't have a built in
support for inserting data( since it
doesn't call the insert method of it
underlying data source when you click
on a button with a CommadName set to
"Insert" ).
The Repeater control : you will find
that it provides a flexible layout but
it doesn't support data grouping
,inserting,deleting , updating and
paging through the data .

The GridView is for tabular data only and does a lot of the work for you, like binding data automatically to columns.
The Repeater gives you more control over the result, but you have to do more because nothing gets binded automatically.
I prefer using a Repeater almost every time, but I can see the usefulness of the GridView.

Related

In Which situation we should use repeater control or Grid View Control in asp.net

I manage a project and as you know asp.net has many types of data control, I am confused which control should be used in what condition. Which is better control in what situation. Should I still use repeater control because grid view is advance control.
A repeater allows you to have your items repeated both horizontally and vertically unlike a GridView which only by default repeat the items vertically.
The best way to understand the two is if you need a simple grid displayed use a gridview.
If you need to do additional formatting or display data from the database with additional graphics, labels, not in a grid type form than use a repeater. You can easily adjust the repeater to by as dynamic as you need it to be where as a grid view is a simple grid.
With a repeater you will click on the page SOURCE of the .Cs or .vb file and you will see 4 templates. Anything HTML you put in those templates will repeat with the data.
Around 2010 I ran into so much trouble with the GridView, I asked a (now former) Microsoft evangelist for advice. He strongly recommended not to use the GridView ever. Then I stopped and life got easier.

Asp.Net Building Impressive DataGrid \ ListView (Webform)

can someone pls give me a reference about building impressive(or just beautiful ) datagrid \ listview.
all my purpose is to show data (not adding data or editing data).
i have one condition that on click on a specific column data it would reference another page (a detailed view).
i have a list object that contains all the data to bind with it.
thanks in advance
This website has some nice CSS table designs. You could pick one of those, download the appropriate CSS file, include it in the page where you have your table and that should be all.
If all you have is just a simple table, I would recommend you use a GridView rather then a DataGrid, mostly because it's easier to make the GridView render the header/footer sections of the table, which are required for the above CSS files to work. (check this questions for example, How do I get Gridview to render THEAD?)
ListView gives you even more control then a GridView, but you have to type some more code yourself (HeaderTemplate, ItemTemplate, AlternatingItemTemplate, etc). If you have scenarios where you need more control over how the table is rendered the ListView would be better choice, but based on what you said (simple tables) I would recommend the GridView

asp.net control for displaying data in a grid

I'm attempting to build a page that displays the same set of information of different "items" in a grid or table. It's akin to a shopping page that displays products in for e.g. a 4 by 3 table.
I came across datagrid and gridview but they display grouped information according to columns and each row representing one item only.
Is there a control that displays data in a very basic grid format instead of tabular form, preferably with built in pagination abilities?
Many thanks in advance
You will want to use a DataList or a Repeater, as those controls allow you to specify the exact HTML you want for each item. Unfortunately, neither of those have built in pagination, but honestly, the built in pagination in the GridView is of questionable usefulness, since it only works if you use a specific data source or load everything from the database up front.
I'm not sure what you mean, you want a basic grid, but gridview doesn't work for you. But in any case, check out the repeater. It will require a bit more work to built a template for your items, but it's very flexible and can handle what you want.

Can database fields be dragged and dropped (as textboxes, not a gridview) into an ASP.Net form?

In VisualStudio, when you drag and drop a table or an individual column from a data connection in server explorer, a gridview is created.
What I want to be able to do is drag and drop the columns to make a quick and dirty detail form to display an individual record. Is this possible in any way?
An even better way to do this would be via a custom T4 or LLBLGen template but I have no clue how to do this.
Any other suggested approaches?
UPDATE: A DetailsView is the type of thing I am looking for, in that you can select a data source and the specific columns you want, but I'd like to be able to have manual control of the layout and formatting after the initial drag and drop.
I suggest binding a DetailsView to the table using a data source (SqlDataSource) instead. You might find these tutorials, especially this one helpful.
In response to your update, have a look at the FormView control. It gives you complete control of the layout using templated sections.
There appears to be literally no way to do this in VS that I have come across.

ASP.Net: How to do pagination with a Repeater?

I'm using the Repeater control on my site to display data from the database. I need to do pagination ("now displaying page 1 of 10", 10 items per page, etc) but I'm not sure I'm going about it the best way possible.
I know the Repeater control doesn't have any built-in pagination, so I'll have to make my own. Is there a way to tell the DataSource control to return rows 10-20 of a much larger result set? If not, how do I write that into a query (SQL Server 2005)? I'm currently using the TOP keyword to only return the first 10 rows, but I'm not sure how to display rows 10-20.
You have to use the PagedDataSource, it allows you to turn a standard data source into one that can be paged. Here's an example article
This isn't a way to page the data, but have you looked into the ListView control? It gives the flexibility of repeater / data list but with built in paging like the grid view.
And for paging in sql, you would want to do something like this
This was answered here.

Resources