ADO Net Database ASP.Net Tutorial

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomParameters.aspx.cs"  Inherits="CustomParameters" %>


    Custom Parameters


    
    

                                 runat="server"
                          ProviderName="System.Data.SqlClient"
                          ConnectionString="<%$ ConnectionStrings:Northwind %>"
                          SelectCommand="SELECT CustomerID, ContactName FROM Customers"/>
                                  runat="server" 
                          DataSourceID="sourceCustomers" 
                          DataTextField="ContactName" 
                          DataValueField="CustomerID" 
                          AutoPostBack="True">
        
                                   runat="server"
                           ProviderName="System.Data.SqlClient"
                           ConnectionString="<%$ ConnectionStrings:Northwind %>"
                           SelectCommand="SELECT OrderID,OrderDate,ShippedDate FROM Orders WHERE CustomerID=@CustomerID AND OrderDate>=@EarliestOrderDate"
                           OnSelecting="sourceOrders_Selecting">
           
              
              
           

      
                          runat="server" 
                    DataSourceID="sourceOrders" 
                    AutoGenerateColumns="False" 
                    DataKeyNames="OrderID" >
            
                                                                    InsertVisible="False" 
                                                    ReadOnly="True" 
                                                    SortExpression="OrderID">
                                    SortExpression="OrderDate">
                                    HeaderText="ShippedDate" 
                    SortExpression="ShippedDate">
            

        
    

    


File: CustomParameters.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CustomParameters : System.Web.UI.Page
{
    protected void sourceOrders_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {        
        e.Command.Parameters["@EarliestOrderDate"].Value = DateTime.Today.AddYears(-10);
    }
}
File: Web.config