Posts tagged 'asp-net'
IronPython for ASP.NET
I just noticed today that Microsoft has released a CTP for IronPython for ASP.NET. Looks interesting. You can take a look at it here.
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"
Forms authentication and images/style sheets
If you are unable to view images and/or a style sheet is not formatting a web form and you are using forms authentication, you'll need to make the below changes to Web.config (assuming that your style sheet is in a directory named style and images in a directory named images). Forms authentication...
Continue reading "Forms authentication and images/style sheets"
Master Pages and User Controls in .NET 2.0
One of the great mysteries of .NET 2.0 is how to reference the class of a master page or user control from code-beside. This is where the MasterType and Reference directives come into play. Master Page (from content page) <% @ MasterType TypeName ="ClassName" %> <% @ MasterType VirtualPath ...
Continue reading "Master Pages and User Controls in .NET 2.0"
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"
Bind does not exist in the current context
If you are using the new Bind() method, but are trying to pass it to a function or perform any other type of manipulation on it, you will get the following error as Bind() only allows for 1 way data binding: Bind does not exist in the current context Instead, you will need to use the following format...
Continue reading "Bind does not exist in the current context"
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"
MVP Nomination
Good news. Tonight I got my MVP nomination from the MVP lead for my contributions to the ASP.NET Community. Yeah!
A special thanks to all that made this possible.
EnsureChildControls
EnsureChildControls is something useful to keep in mind when creating properties that get/set properties on controls present in, for example, a web form or master page. If the control has not yet been created, you will get a runtime error. What EnsureChildControls does is checks if the child controls...
Continue reading "EnsureChildControls"
Which AJAX control is right for me?
There are many AJAX controls out there, but which one is right for you? Daniel Zieb put together a comprehensive comparison of 6 different AJAX controls and reported on their performance in a very excellent article. Welcome to my comparison of AJAX frameworks for ASP.NET...
Continue reading "Which AJAX control is right for me?"
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"
A better way to parse query string values for non-string data types
Occasionally, I've glanced at the TryParse method in IntelliSense, but never gave it a test run. TryParse is actually pretty cool. It will try to parse a string and see if it can convert it to a specified data type. This is perfect for query strings as you don't have to mess with testing for null values...
Continue reading "A better way to parse query string values for non-string data types"
MasterPage Property Woes
For some reason I'm not able to access public properties that I declare in a MasterPage, even though it is supposed to work. So, I discovered a way around it was to use FindControl. The example below demonstrates accessing a Literal control with an ID of litText in a MasterPage file. VB.NET Dim lit As...
Continue reading "MasterPage Property Woes"
HttpContext Helper
Need to access an HttpContext object in a class, but can't because the class doesn't inherit System.Web.UI.Page? Here is a simple helper class that will allow you to access some of the most common HttpContext objects. C# using System; using System.Web; using System.Web.Caching; using System.Web.SessionState;...
Continue reading "HttpContext Helper"
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?"
MagicAjax - Easy as 1, 2, 3
A couple of days ago I discovered MagicAjax. MagicAjax simplifies creating Ajax enriched content. So, how do you use MagicAjax? Click here to download MagicAjax. Step 1 Add a reference to the MagicAjax assembly to your project or a copy of it to the bin directory if you are not using an IDE. Also, add...
Continue reading "MagicAjax - Easy as 1, 2, 3"
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"
Common DropDownList Issue
A common DropDownList issue I've seen on many forums and lists is about a DropDownList populating items 2x or not being able to get the selected value on postback when binding to a data source. This is due to the DropDownList having data bound to it again on postback before the form is processed. To...
Continue reading "Common DropDownList Issue"
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"




