asp.net control for displaying data in a grid - asp.net

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.

Related

ASP.NET Design Issue: what is the best asp.net control for creating a table with 15 properties?

I am a new ASP.NET developer and now I need to develop a data entry system with 15 fields that allow the admin of the system to enter some data under each one of these 15 properties. From what I learned in ASP.NET tutorial, I think the best control is the ListView control in order to give the admin of the system to enter a new field if he wants in the future. My problem now is the following:
How to divide these 15 fields into two columns? Because all what I see about using ListView is putting all of the properties at the first row and the entries will be underneath of them. What I want is to create a list with two columns of properties and two columns for the entries
I'm not sure that a ListView makes sense from your description. Are your administrators updating the same properties on different objects? Like most of the ASP.NET controls in its class -- the Repeater and GridView are other similar examples -- the ListView is meant to create several rows of identical information based on an HTML template you provide.
If your administrators are creating or updating:
The same property for different objects, then the ListView, Repeater, or GridView would be fine.
Different properties for the same or different objects, then you need a more traditional form with normal data entry controls (like the TextBox, HtmlSelect or DropDownList, CheckBox, etc.)
I would use a more liberate approach and code the fields my self into the view you'd like.
At first it might take more time, but after that your would be able to control the look of it much quicker and easily.
Using a listView you can build your edit/input gui as you'd like - a table or any other way. If really must divide into 2 columns - you could just put a label and then the field just underneath it. 7 on one side and 8 on the other.
If you're looking to use the edit features of a data control, you could create a custom item template for your data control (be it a gridview or whatnot) that has a table and each of the properties (I assume all 15 are conisidered 1 row of data). Bind your single row to the data control and it should work. You could even have different template views for display and editing using the templates.

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

Why not we use Repeater Control instead of Gridview Control?

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.

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