Archive / ASP.Net

RSS feed for this section

Entity Framework Filter Child Entity

I was looking for a way to filter child entities with eager loading. I ran into this useful blog post by Beth Massi on the subject. Here is the code I ended up using. It doesn’t work with server-side paging, but I didn’t need it in this case. Dim query = (From x In db.OrderChecklistItems […]

Entity Framework GridView RowDataBound

I found it tricky to get actual entities in the GridView RowDataBound event. Per Diego Vega’s post here, this may only happen because I am using the EntitySetName property of the EntityDataSource.     Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then             Dim descriptor As ComponentModel.ICustomTypeDescriptor […]

How to Hash Passwords for XML Files

To save a password hash to an XML file, you can call this function: FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text & "|" & txtUsername.Text, "SHA1") You can see my attempt at a password salt by simply apppending the Username.

GridView Row Index in Markup

Sometimes I want to show the e.Row.RowIndex of a GridViewRow in the markup of the page. I don’t want to hook into the RowDataBound method just to display a simple number. The answer varies for GridViews and Repeaters. Click here for the complete rundown. GridView: <asp:Literal runat="server" Text='<%# Container.DataItemIndex + 1 %>' /> Repeater: <asp:Literal […]

.Net Options for Data Access

Data Access Practices Using Microsoft .Net: A Nerdly Comparison In this article a comparison of these options: – Connected Data Access with ADO.NET– Disconnected Data Access with ADO.NET and Typed DataSets– Basic Object Relation Mapping with LINQ to SQL– Object Relational Mapping with LINQ to Entities and the Entity Framework See also: Extending NerdDinner: Exploring […]

Truly Understanding ViewState

I was having some troubles with large ViewStates, so I found this article. It does an excellent job of explaining the inner workings of ViewState, and some of the common ways to misuse it. http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx – Zachary