Laying out data with the ASP.NET data controls - asp.net

I am trying to learn about ways to layout my data from a database using ASP.NET and C#
I can layout my data without any problem in rows using things like the GridView control, as the below image illustrates.
However I want to layout all of the information that would normally be in 1 row, in 1 cell.
So for example, each row would have 3 cells, each cell containing all of the information from 1 database row, as the image below illustrates.
Is there any way to do this with the existing ASP.NET controls, for example with a Gridview, or do I have to just build the table myself?
Any help would be greatly appreciated.

You can achieve this using asp.net DataList server control. Its very similar to Repeater except you can also display data horizontally using RepeatColumns property. For more detail on using please have a look at http://www.builderau.com.au/program/dotnet/soa/Formatting-data-in-columns-with-ASP-NET-s-DataList-control/0,339028399,339270702,00.htm and http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.repeatcolumns.aspx

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.

Displaying records in a nice layout

I have a database where I want to display 2 records in a nicely formatted ASP.NET with HTML
Each record would look like this on the web page
The layout would be layers. The data is in a SQL Server 2008 r2 database.
Now whats the best way to get data to populate each record.
Repeater? Or another method?
Regards
Tea
The repeater control is an easy control to use to make sure that your data is displayed the same for all entries in a given data source.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.aspx
This looks like a template and will follow the same html for each entries so it would be better to go for repeater as you will have more control over the html,css and the placemnet part.
yes repeater is best option to use in this situation or you can generate the whole html on you code behind page and assign it to a literal control.

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

control that has paging but supports custom format

i need to know what control in asp .net 2.0 to use to get this layout:
i need to display 8 videos at a time using 2 rows with 4 columns, but the control should also have paging (to display 8 items per page).
i've thought of using a formview but the paging for formview is per one article content / datarow only.
i'm also thinking of using gridview but i am not so sure if i can get this layout.
any thoughts please.. very much appreciated.. thank you!
For the above scenario i think yo can make use of DataList control of ASP.NET which can help you to make the controls in columns and rows order. You will have to create a Paging Programatically.
I am giving you the link which can help you to create a paging with Repeater Control.
Preferred: http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx
http://www.dotnetcurry.com/ShowArticle.aspx?ID=345
http://www.developer.com/net/asp/article.php/3646011/ASPNET-Tip-Creating-Paging-for-a-Repeater-Control.htm
http://www.codeproject.com/KB/webforms/Aspnet_Repeater_Control.aspx

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.

Resources