Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Tagged as

Gridview Sorting using attribute [Source Code]

, 30 Aug 2013
Sorting GridView using attribute property of GridView
demo.zip
demo of my project
App_Code
App_Data
database
database.bak
Thumbs.db
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

/// <summary>
/// Summary Descriptionfor Dal
/// </summary>
public class Dal
{
    SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ankit_connection_string"].ConnectionString);
    SqlCommand cmd = new SqlCommand();
    SqlDataAdapter da = new SqlDataAdapter();
    DataSet ds = new DataSet();
    DataTable dt = new DataTable();
    public Dal()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public int insert(string Rewards_Type, string description, string Alias, Boolean Prescribed, Boolean nonprescribed, string Points, string Points_Amount, string Conversion_Point, string Conversion_amount)
    {
        cn.Open();
        SqlCommand cmd = new SqlCommand("Ankit_insert", cn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Rewards_Type", Rewards_Type);
        cmd.Parameters.AddWithValue("@description", description);
        cmd.Parameters.AddWithValue("@Alias", Alias);
        cmd.Parameters.AddWithValue("@Prescribed", Prescribed);
        cmd.Parameters.AddWithValue("@nonprescribed", nonprescribed);
        cmd.Parameters.AddWithValue("@Points", Points);
        cmd.Parameters.AddWithValue("@Points_Amount", Points_Amount);
        cmd.Parameters.AddWithValue("@Conversion_Point", Conversion_Point);
        cmd.Parameters.AddWithValue("@Conversion_amount", Conversion_amount);

        try
        {
            return cmd.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            cn.Close();
        }
    }
    public DataTable select()
    {
        cn.Open();
        SqlCommand cmd = new SqlCommand("ankit_select",cn);
        cmd.CommandType = CommandType.StoredProcedure;
                try
        {
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
        catch
        {
            throw;
        }
        finally
        {
            cmd.Dispose();
            //con.Close();
            //con.Dispose();
        }
    }
    public DataTable select1()
    {
        cn.Open();
        SqlCommand cmd = new SqlCommand("ankit_select1", cn);
        cmd.CommandType = CommandType.StoredProcedure;
        try
        {
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
        catch
        {
            throw;
        }
        finally
        {
            cmd.Dispose();
            //con.Close();
            //con.Dispose();
        }
    }
    public int delete(int id)
    {
        try
        {
            cn.Open();
            SqlCommand cmd = new SqlCommand("Ankit_Delete", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ankid",id);
            return cmd.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            cn.Close();
        }
    }
    
    public DataTable get(int Id,string Rewards_Type, string description, string Alias, Boolean Prescribed, Boolean nonprescribed, string Points, string Points_Amount, string Conversion_Point, string Conversion_amount)
    {
        cn.Open();
        SqlCommand cmd = new SqlCommand("ankit_select", cn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Id", Id);
        cmd.Parameters.AddWithValue("@Rewards_Type", Rewards_Type);
        cmd.Parameters.AddWithValue("@description", description);
        cmd.Parameters.AddWithValue("@Alias", Alias);
        cmd.Parameters.AddWithValue("@Prescribed", Prescribed);
        cmd.Parameters.AddWithValue("@nonprescribed", nonprescribed);
        cmd.Parameters.AddWithValue("@Points", Points);
        cmd.Parameters.AddWithValue("@Points_Amount", Points_Amount);
        cmd.Parameters.AddWithValue("@Conversion_Point", Conversion_Point);
        cmd.Parameters.AddWithValue("@Conversion_amount", Conversion_amount);

        try
        {
            da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }
        catch
        {
            throw;
        }
        finally
        {
            //cmd.Dispose();
            cn.Close();
            //con.Dispose();
        }
    }

    public int update(int Id, string Rewards_Type, string description, string Alias, Boolean Prescribed, Boolean nonprescribed, string Points, string Points_Amount, string Conversion_Point, string Conversion_amount)
    {
        cn.Open();
        SqlCommand cmd = new SqlCommand("Ankit_update1", cn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Id", Id);
        cmd.Parameters.AddWithValue("@Rewards_Type", Rewards_Type);
        cmd.Parameters.AddWithValue("@description", description);
        cmd.Parameters.AddWithValue("@Alias", Alias);
        cmd.Parameters.AddWithValue("@Prescribed", Prescribed);
        cmd.Parameters.AddWithValue("@nonprescribed", nonprescribed);
        cmd.Parameters.AddWithValue("@Points", Points);
        cmd.Parameters.AddWithValue("@Points_Amount", Points_Amount);
        cmd.Parameters.AddWithValue("@Conversion_Point", Conversion_Point);
        cmd.Parameters.AddWithValue("@Conversion_amount", Conversion_amount);

        try
        {
            return cmd.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            cn.Close();

        }

    }
}

   
   
   

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

AJD-salute
Web Developer
India India
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 31 Aug 2013
Article Copyright 2013 by AJD-salute
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid