Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET 1.1
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 16th, 2007, 03:41 AM
Authorized User
Points: 270, Level: 5
Points: 270, Level: 5 Points: 270, Level: 5 Points: 270, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2006
Location: thrissur, kerala, India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 8:datagrid sorting not working

hi friends,
 I have written the code as below for sorting the datagrid columns.but its not working.please check the code and help me to overcome my problem..
************************************************** *****************
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebApplication1.images
{
        public class sort : System.Web.UI.Page
    {
        protected System.Web.UI.WebControls.DataGrid DataGrid1;

        private void Page_Load(object sender, System.EventArgs e)
        {

            if (!Page.IsPostBack )

            {

                BindGrid();

            }
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

        public void DataGrid_Page(object sender, DataGridPageChangedEventArgs e)
        {
            DataGrid1.CurrentPageIndex = e.NewPageIndex;
            BindGrid();
        }

        public void DataGrid_Sort(object sender, DataGridSortCommandEventArgs e)
        {
DataGrid1.CurrentPageIndex = 0;
            SortField = e.SortExpression;
            BindGrid();



        }

        protected String SortField
        {
            get
            {
                object o = ViewState["SortField"];
                return (o == null) ? String.Empty : (String)o;
            }
            set
            {
                ViewState["SortField"] = value;
            }
        }
        void BindGrid()
        {
            SqlConnection con3=new SqlConnection("server=localhost;Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=vms_database;Data Source=server0");
            string CommandText;
            if(SortField == String.Empty)
                CommandText = "select * from Admin_ringtone order by songname";
            else
                CommandText = "select * from Admin_ringtone order by" + SortField;
            SqlDataAdapter ad = new SqlDataAdapter("select * from Admin_ringtone ",con3);
            DataSet ds = new DataSet();
            ad.Fill(ds,"Admin_ringtone");
            DataGrid1.DataSource = ds;
            DataGrid1.DataBind();

        }
    }
}
__________________
sumith
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid sorting Amorous ASP.NET 1.x and 2.0 Application Design 1 September 30th, 2005 11:44 PM
Chapter 17 - DataGrid Sorting Example Appled BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 4 March 28th, 2005 03:13 PM
Sorting not working correct Vishal_7 ASP.NET 1.0 and 1.1 Professional 0 February 21st, 2005 01:28 PM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
Sorting Is not working alyeng2000 ASP.NET 1.0 and 1.1 Basics 3 March 2nd, 2004 06:22 AM



All times are GMT -4. The time now is 08:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.