Using ASP.NET Web Forms, Passing Primary Key to RowCommand Event

  I know this is old hat, but after recently having a conversation with one of the ASP.NET Team guys about how easy Web Forms is to use, I thought I’d just post a simple example of that.  Here is the scenario.  You have a simple GridView with just three columns (Select,Id,TagName).  You want to be able to capture what happens when the user pressed the Select command and capture the Id.  It looks like this:     And has an aspx page like this:   <asp:GridView ID="GridViewNotSelected" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSourceTagsNotSelected" … Continue Reading

How to Disable Edit/Insert/New Buttons in DetailsView or GridView (ASP.NET 2.0+)

So, this is kind of embarrassing, that it took me a while to figure this out.  I have not been doing pure server control programming for a while, but I figure since it took me a while, maybe there is someone else in the same boat. So, you have a GridView or DetailsView that has standard “Edit” “Update” “New” type command buttons on them.  The way they get there is by having the declaration something like this: … Continue Reading

How To Access Content From MasterPage in ASP.NET

So, you want to access some content from inside a page that you created from an existing master page?  The most clean way to do this is to create a public property in your master page, then access that.  In my case, I have a search button on a master page that I want to use from inside to pages that derive from that page.  So, Here is how I declare my master page: 1: <%@ Master Language="C#" MasterPageFile="~/MasterPages/MasterPage.Master" AutoEventWireup="true" 2: CodeBehind="ContactMasterPage.master.cs" Inherits="ThreePLogic.Web.ASPWeb.ContactPages.ContactMasterPage" %> 3:  4: <asp:Content ID="Content5" … Continue Reading

How to Retrieve a GridView Based on a CheckBoxList of Items with Asp.Net using ObjectDataSource with a little LINQ Thrown In

So, the problem is you have a list that you want to retrieve from that contains multiple values.  Say for example, you have a list of 5 cities and you want to retrieve a list of people in some combination of those cities.  If you use the class SelectValue method with GridView you run out of steam because it's only one value.  What you'd really like to do is pass the CheckBoxList into the GridView as a selection parameter, but unfortunately, when you do that, you just get the one selected value from the CheckBoxList, not all the values. I'm sure you can make a custom ControlParameter in ObjectDataSource to solve this, but I really don't have time for that.  I just wanted something quick (which I now have and thought I'd … Continue Reading


Get every new post delivered to your Inbox

Join other followers: