.NET news » Search results
Search results for query "gridview" (24):
How to click/select Row in ASP.NET GridView or HTML Table
GridView Enhancements and Fixes
Custom Formatting Based Upon Data (C#)
The appearance of the GridView, DetailsView, and FormView controls can be customized through myriad style-related properties. Properties like CssClass, Font, BorderWidth, BorderStyle, BorderColor, Width, and Height, among others, dictate the general appearance of the rendered control. Properties including HeaderStyle, RowStyle, AlternatingRowStyle, and others allow these same style settings to be applied to particular sections. Likewise, these style settings can be applied at the field level.
In many scenarios, though, the formatting requirements depend upon the value of the displayed data. For example, to draw attention to out of stock products, a report listing product information might set the background color to yellow for those products whose UnitsInStock and UnitsOnOrder fields are both equal to 0. To highlight the more expensive products, we may want to display the prices of those products costing more than $75 in a bold font.
Adjusting the format of the GridView, DetailsView, or FormView based upon the data bound to it can be accomplished in multiple ways. In this tutorial, we'll look at how to accomplish data bound formatting through the use of the DataBound and RowDataBound event handlers. In the next tutorial we'll explore an alternative approach...
Custom Paging without Changing/Breaking SQL Query in GridView
Custom Paging in ASP.NET 2.0 with SQL Server 2005
AllowPaging property to True and add a few lines of code in the PageIndexChanged
event handler and you were done! ASP.NET 2.0's
GridView makes
the process even simpler - just check the Enable Paging option from the GridView's smart tag - no code needed.
Of course nothing is free in life, and the tradeoff you make with the ease of checking a checkbox to enable paging (or, in the DataGrid's case, writing a couple lines of code) is performance. Out of the box, the DataGrid and GridView use default paging, which is a simple paging model that returns all of the records for each every page of data shown. When paging through small amounts of data (dozens to a hundred or so records), this inefficiency is likely outweighed by the ease of adding the feature. However, if you want to page through thousands, tens of thousands, or hundreds of thousands of records the default paging model is not viable.
The alternative to default paging is custom paging, in which you are tasked with writing code that intelligently grabs the correct subset of data. It requires a bit more work, but is essential when dealing with sufficiently-sized data...
HTML5 Tables formatting: alternate rows, color gradients, shadows
Effective Paging with GridView Control in ASP.NET
Fixed Table Header atop scrollable GridView in ASP.NET
ASP.NET e-Commerce GridView with Product Comparisons
Displaying Files and Folders in a GridView
The .NET Framework provides a variety of classes in the System.IO namespace that
simplify working with the file system. Using these classes it's possible to delete files and folders, to create new files, to edit existing files, and more. These
classes, combined with ASP.NET's suite of Web controls and databinding syntax, make it quite easy to present information about the files on the web server's file system
to visitors to your website. With a bit of markup and code, it's possible to add a simple file browser to a web page that allows users to view the files and folders from
a particular directory on the web server. Such file browsers are useful if you let users upload content to the website and need to let them view their uploaded content.
If you have a folder that contains user-accessible content like images, PDF files and Word documents, a file browser offers a quick and easy way for users to see what
content is available and to view content of interest.
Back in 2003 I wrote an article titled Displaying the Files in a Directory using a DataGrid that showed how to list the files of a particular folder in a DataGrid Web control. This dated article still attracts a decent amount of traffic and questions from readers, so much so that I thought it worthwhile to update the content to use the latest technology, namely ASP.NET 4 and the GridView Web control. I also added some new features. For example, the file browser now lists both files and folders, allowing users to view the files in subfolders. Also, I moved the markup and code into a User Control, which simplifies adding the file browser to an ASP.NET page. This article walks through this new, updated version; the complete, working code is available for download at the end of this article.


Syndicate