Thread: SortCommand Event

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    SortCommand Event

    I hope I give you enough info below. Basically I have a DataGrid dgQuick with AllowSorting set.

    When I click one of the header title to invoke the DataGridSortCommandEventHandler, the section B is only executed if line A exists. I need to be able to execute section B without having line A.

    Code:
            private void Page_Load(object sender, System.EventArgs e)
            {
                dgQuick.SortCommand +=
                    new DataGridSortCommandEventHandler(dgQuick_SortCommand);
    
                if (!Page.IsPostBack)
                {
                    bindData("ID");
                } 
                bindData("Subject");  // LINE A ####
            }
    
            private void dgQuick_SortCommand(object source,
                DataGridSortCommandEventArgs e) 
            {
                // SECTION B ####
                Response.Write("dgQuick_SortCommand");
                bindData(e.SortExpression);
            }
    
            private void bindData(String sortExpression) 
            {        
                Response.Write(sortExpression);
                taskManager = new TaskManager(Server.MapPath(@"data\data.xml"));
                TaskList ts = taskManager.GetTaskList();
               
                TaskComparer comparer = new TaskComparer(sortExpression);
                ts.Sort(comparer);
              
                dgQuick.DataSource = ts;
                dgQuick.DataBind();
    
            }
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Solved it. The problem was I had the EnableViewState set to false
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

Popular pages Recent additions subscribe to a feed