Tech Off Thread

1 post

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

sort function is not working properly during first click??

Back to Forum: Tech Off
  • User profile image
    venkatzeus

    HI..

    I have a web application, in which i have a r.a.d datagrid. i have kept sorting to true in the datagrid. When the user clicks on the field caption at the first time, the records are not getting sorted. If the user clicks again the records are sorted. Below is the code:

    protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)

    {

    //dgSchedule is the name of the grid. 

    if (!(source == this.dgSchedule))

    {

    base.RaisePostBackEvent(source, eventArgument);

    // if there is data in the Grid and none of the rows are selected.

    if (dgSchedule.Items.Count > 0 && dgSchedule.SelectedItems.Count <= 0)

    {

    if (ViewState["ScheduleClickedItem"] != null && Convert.ToInt32(ViewState["ScheduleClickedItem"]) > 0)

    {

    // if the already selected row is in the ViewState means, the selection is made to it.

    dgSchedule.Items[

    Convert.ToInt32(ViewState["ScheduleClickedItem"])].Selected = true;

    }

    else

    {

    // if there is no row selected previously means, the selection is made to the first row.

    dgSchedule.Items[0].Selected = true;

    }

    }

    return;

    }

    // during the first sort click, the control is getting passed over here(but it should not), and it calls the ColumnsReorder case.

    else if ((source == this.dgSchedule))

    {

    // argument passed from the javascript.

    string[] postBackEventArgumentData = eventArgument.Split(',');

    switch (postBackEventArgumentData[0])

    {

    case "RowClick":

    string[] rowClickedEventArgumentData = postBackEventArgumentData[1].Split(':');

    dgSchedule.Items[rowClickedEventArgumentData[1]].Selected =

    true;

    // stores the selected row state in the viewstate, for further selection.

    ViewState[

    "ScheduleClickedItem"] = rowClickedEventArgumentData[1];

    // gets the id of the selected row from the argument passed by the java script.

    string ScheduleId = dgSchedule.Items[rowClickedEventArgumentData[1]]["RowId"].Text;

    BindSchedulerMgntGrid();

    break;

    case "ColumnsReorder":

    BindSchedulerMgntGrid();

    break;

     

    }

    }

    please help....

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.