ADO Database ASP.Net

<%@ Page Language="C#" %>

    void deptView_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            string imageUrl = (deptView.SortDirection==SortDirection.Ascending ?"Asc.gif" :"Desc.gif");        
            for(int i=0; i            {
                string columnExpression = deptView.Columns[i].SortExpression;
                if (columnExpression != "" && columnExpression == deptView.SortExpression)
                {
                    Image img = new Image();
                    img.ImageUrl =imageUrl;
                    e.Row.Cells[i].Controls.Add(img);                    
                }
            }        
        }
    }    



  Adding Indicators to display Sorting Direction


  
    

                          AllowSorting="true" 
                    runat="server"
                    AutoGenerateColumns="false" 
                    DataSourceID="deptSource"
                    OnRowCreated="deptView_RowCreated">
        
                                    DataField="DepartmentID" 
                          SortExpression="DepartmentID" />
          
                    
        

      
                               Runat="server" 
                         SelectCommandType="Text"
                         SelectCommand="Select DepartmentID, Name, GroupName, ModifiedDate from HumanResources.Department" 
                         ConnectionString="<%$ConnectionStrings:AdventureWorks%>">