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(); }