Posts tagged 'gridview'
C# GridView Sorting/Paging w/o a DataSourceControl DataSource
If you set AllowPaging="true" or AllowSorting="true" on a GridView control without using a DataSourceControl DataSource (i.e. SqlDataSource, ObjectDataSource), you will run into the following errors: When changing the page on the GridView control: The GridView 'GridViewID' fired event...
Continue reading "C# GridView Sorting/Paging w/o a DataSourceControl DataSource"
VB.NET GridView Sorting/Paging w/o a DataSourceControl DataSource
If you set AllowPaging="true" or AllowSorting="true" on a GridView control without using a DataSourceControl DataSource (i.e. SqlDataSource, ObjectDataSource), you will run into the following errors: When changing the page on the GridView control: The GridView 'GridViewID' fired event...
Continue reading "VB.NET GridView Sorting/Paging w/o a DataSourceControl DataSource"
2 Awesome Blog Posts By Doug Nelson
I came across two awesome blog posts by Doug Nelson. Optional Parameters for Stored Procedures GridView Dissapointments...
Continue reading "2 Awesome Blog Posts By Doug Nelson"
GridView without DataSourceControl DataSource Updated
I just updated my GridView without DataSourceControl DataSource blog entry and all code to allow sort state and data to persist between page changes. Updates: GridView without DataSourceControl DataSource GridView without DataSourceControl DataSource C# Code Download GridView without DataSourceControl...
Continue reading "GridView without DataSourceControl DataSource Updated"
Sorting and EnableSortingAndPagingCallbacks
I've discovered that using EnableSortingAndPagingCallbacks="true" without a DataSourceControl data source causes sorting not to work. While I don't know exactly why this happens, I'm hoping this blog entry will save a lot of people from banging their head on the table. Update: I found the answer on MSDN...
Continue reading "Sorting and EnableSortingAndPagingCallbacks"
GridView without DataSourceControl DataSource: VB.NET Version
I just created the VB.NET version of the sample that I posted at GridView without DataSourceControl DataSource Part II . Live Example Code Download...
Continue reading "GridView without DataSourceControl DataSource: VB.NET Version"
GridView without DataSourceControl DataSource Part II
I've created a live working example of my blog entry GridView without DataSourceControl with source code. Live Example Code Download...
Continue reading "GridView without DataSourceControl DataSource Part II"
Generic List Collection / ObjectDataSource / GridView Sample
I put together sample code that will run on the Northwind database that demonstrates using a generic List collection as a data source for an ObjectDataSource which populates a GridView control. All you have to do is specify the connection string in Web.config and the sample code will run. Enjoy. Download...
Continue reading "Generic List Collection / ObjectDataSource / GridView Sample"
Why doesn't a link in a HyperLinkField render?
It appears that there is a security feature built-in to the HyperLinkField that causes links that resemble JavaScript functions (i.e. java script:SomeFunction()), file paths (i.e. F:\Directory\File), and other non-URL strings not to render when using the DataNavigateUrlFormatString property. The only...
Continue reading "Why doesn't a link in a HyperLinkField render?"
Useful export helper class
Below is a helper class that I use for exporting a DataGrids contents to an external file. The below code references gridViewText, but I haven't tested it out on a GridView yet as the code is from an application I'm working on upgrading. But, it works like a charm on the DataGrid. public sealed class...
Continue reading "Useful export helper class"
GridView without DataSourceControl DataSource
If you're like me and converting a .NET 1.1 application to 2.0, and aren't using a DataSourceControl DataSource just yet but need to enable sorting and paging, you might run into the following exceptions: When changing the page: The GridView 'GridViewID' fired event PageIndexChanging which wasn't handled...
Continue reading "GridView without DataSourceControl DataSource"
GridView control didn't update or dissapeared. What gives?
This is a common issue even with the DataGrid control. PostBack is invoked and your GridView doesn't update or, in some cases, disappears. All you need to do is force the GridView to bind to its datasource by calling the DataBind() method, GridView.DataBind(), where GridView is the placeholder for the...
Continue reading "GridView control didn't update or dissapeared. What gives?"
Getting the content of a GridView cell on edit
Another common question I see on forums and lists is how to get the content of a GridView cell when in Edit mode. The following code demonstrates how to get the text of a cell at index position 3 using an OnEditing event. VB.NET Private Sub GridView_RowEditing( ByVal sender As Object , ByVal e As GridViewEditEventArgs...
Continue reading "Getting the content of a GridView cell on edit"
What's wrong with Eval()?
The .NET Framwork 2.0 introduces Eval() . Eval() is a shortcut for Container.DataItem() . Since Eval() uses Reflection, it causes overhead. From a optimization standpoint, it is better to use Container.DataItem() . VB.NET Container.DataItem() C# DataReader: ((System.Data.Common.DbDataRecord)Container...
Continue reading "What's wrong with Eval()?"
Multiple DataKeys Null Conditional
Lets say you have multiple DataKeys assigned to the DataKeyNames property of the GridView control where only one DataKey will have a value and the rest will be null. Based on the non-null value, you want to trigger a conditional. I've discovered an easy to accomplish this is using Reflection and a GridView...
Continue reading "Multiple DataKeys Null Conditional"
O DataKeyNames, Where Art Thou?
The GridView control has a cool feature that allows you to bind more than one value as a DataKey. However, the documentation that I could find on how to get a DataKey other than the primary key was sparse. I finally discovered: VB.NET GridView.DataKeys(Index1).Values( Index2) C# GridView.DataKeys[Index1...
Continue reading "O DataKeyNames, Where Art Thou?"
When GridView Paging Goes Bad
Here is something that many people may not know about GridView paging: Interface paging, the method of paging used by the GridView control, causes all your data to be loaded into memory at the time the data binds to the GridView. This means that if you are returning a huge amount of records, you will...
Continue reading "When GridView Paging Goes Bad"
GridView Sorting
I discovered that the GridView lacks a feature when it comes to sorting. What if you are using a DataSource such as SqlDataSource, but you don't want to sort the GridView using the same SelectCommand statement that was used to bind the GridView to its datasource? Using the OnSorting event of the GridView...
Continue reading "GridView Sorting"
GridView Dynamic Button Frustrations
Today I spent 8 hours trying to figure this one out. I was using a CommandField control with ShowDeleteButton="true" in a GridView to handle deletion of records from a database table. Under certain circumstances, it caused a runtime exception. The only fix was to dynamically add the button to a TemplateColumn...
Continue reading "GridView Dynamic Button Frustrations"
Changing an AutoGenerateButton in GridView
I spent about an hour tonight trying to figure out how to change the text of the HyperLink generated by the GridView controls AutoGenerateSelectButton property when set to true. To do so, you must set it to false (default value) and use a CommandField control. You can do the same for any of the AutoGenerateButton...
Continue reading "Changing an AutoGenerateButton in GridView"




