Easily Absorb Multiple Web Controls Via NameSpace Reference

Instead of having multiple references to separate controls in your pages. You can put all of them under 1 namespace and reference the single NameSpace. This will allow all controls under this namespace to be accessible.

Create the control by adding a new class into the App_Code directory. In the class definition make sure it inherits CompositeControl.

State Web Control DropDown Field

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using AppName.Objects;

/// <summary>
/// Summary description for StateDropDown
/// </summary>

namespace AppName.WebControls.Fields
    public class StateDropDown : CompositeControl

        public StateDropDown() { }

        // Private Properties
        #region Private Properties
        // Controls   
        private DropDownList _DropDownList = new DropDownList();
        private LiteralControl _LitExample = new LiteralControl();

        // Internal Properties (formerly stored in ViewState)
        private bool _IsExampleVisible = true; // Example is visible by default
        private bool _IsRequired = false;
        private string _OverrideExample = "";
        private State.StateType _StateType = State.StateType.All; // Show all states by default
        private string _ValidationGroup = "";

To use this new control or any control under this namespace simply reference the NameSpace directly within your ASPX.

<%@ Page Language="C#" Theme="LightTheme" %>
<%@ Register TagPrefix="fields" Namespace="AppName.WebControls.Fields" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="AppName.Objects" %>

<script runat="server">
    // Protected Properties   
    protected enum PageStateName

<div class="field">                         
     <fields:StateDropDown ID="DdlState" runat="server" IsRequired="false"></fields:StateDropDown>

How To Print The Current Row Number In An ASP.NET Repeater Control


<%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>

Example implementation 1:

<asp:Repeater ID="rep1" runat="server' DataSourceID="myds">
<%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>
<-- other data binding expressions here... -->

Example implementation 2:

 <td class="c1">
         1. CVS
         109 South High Street
         Columbus, OH 43215
         Get Directions
      <%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>.
      <%# Eval("LocationName")  %></b><br />
      <%# Eval("Address")%><br />
      <%# Eval("City")%>,
      <%# Eval("State")%>
      <%# Eval("Zip")%>
     <br />
      <a target="_blank" href='http://maps.google.com/maps?f=q&hl=en&q=from:<%= AddressEntered %>+to:<%# Eval("address") %>, <%# Eval("city") %>,<%# Eval("state") %>,<%# Eval("zip") %>'>Get Directions</a>

How To Convert a DataSet into a Class

  • Open the Visual Studio .NET command prompt and browse to the directory where your XSD file exists.
  • Type the following at the prompt: xsd.exe SchemaName.xsd /DataSet /language:CS, where SchemaName.xsd is the name of your XSD file. In this example, the command line looks like this: xsd.exe Customers.xsd /DataSet /language:CS. For Visual Basic .NET, use /language:VB.
  • Look for your generated class file. In this sample, a file named Customers.cs will be created.
  • There are several options and flags for the xsd.exe tool, but the important flag for creating your strongly typed DataSet object is the /DataSet flag. This tells the tool to parse through the XSD file and autogenerate a strongly typed DataSet object for you. A view of the command line looks like this:

    C:\>xsd.exe Customers.xsd /DataSet /language:CS
    Microsoft (R) Xml Schemas/DataTypes support utility
    [Microsoft (R) .NET Framework, Version 1.1.4322.573]
    Copyright (C) Microsoft Corporation 1998-2002.
    All rights reserved.

    Writing file 'C:\Customers.cs'.