GridView
Export GridView or Other Data as Microsoft Excel (CSV) File with C#
The following is a quick and easy way to export a list of data to a comma separated file (CSV). The nice thing about CSV is that Microsoft Excel can open it directly and it reads just like a simple Excel document. The rules of CSV are pretty straight forward:
- Values in the CSV file must be separated by a comma.
- The values must match the exact count of each row. If a specific column value is empty, make sure to place a "," as a placeholder for that value so it retains the same order.
- Each line in the file must end with a line break (CR or CRLF).
Find a control in a TemplateField programmatically
When you add a DetailsView or GridView control to your page, you may need to programmatically access that control in the code behind. You might look at the System.Web.UI.Page object and see it has a FindControl (http://msdn2.microsoft.com/en-us/library/31hxzsdw.aspx) method built in for you. If you thought that you could get ANY control on the page...
You would be wrong.
GridView ObjectDataSource LINQ Paging and Sorting
If you've attempted to create your own Data Access Layer for LINQ and want to use the built-in data binding for .NET controls like a GridView, you know the nightmare of trying to get these controls to work together with LINQ new IQueryable interface. After much pain and suffering, I was able to cobble together little tidbits from various posts to create a solid object that can be used as a "codeless" ObjectDataSource for any GridView AND support sorting, paging, and filtering just like if you were to databind to a LINQ to SQL object (like EVERY tutorial shows you how to do).

Recent comments
14 hours 12 min ago
1 day 14 hours ago
3 days 15 hours ago
4 days 4 hours ago
4 days 15 hours ago
4 days 21 hours ago
5 days 55 min ago
1 week 21 hours ago
1 week 1 day ago
1 week 4 days ago