how to get radgrid prevous row's index id

2 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 17 Feb 2013 Link to this post

    Question 1:

    I have a radgrid, the key index id QuestionID (DataKeyNames="QuestionID"). I have a move Up and Down radbutton - template column.   I need to switch the order when click the move up and down. At my back table, there is a field ordernumber, everytime I click the Up/Down, I need to update the ordernumber in back db and rebind the grid.  Is there a way that I can find the previous row's QuestionID on "ItemCommand" server side when I click "Up" button so that I can update the ordernumber for previous row?

    I am able to make this work on a grid without filter. Basic I get QuestionID from my QuestionList, but after after filtering of the grid, it doesn't work any more, since my  QuestionList still the original QuestionList, not the List after filtering. Not sure how to get the QuestionList on serverside after filtering.

    Question 2:

    I need hide one of the column when do the filtering, how I do that?

    Thank you!
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Feb 2013 Link to this post


    Try the following code to achieve your scenario.
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
          if (e.CommandName == "CommandName")
           if (e.Item is GridDataItem)
                  GridDataItem item = (GridDataItem)e.Item;
                  string value = RadGrid1.MasterTableView.DataKeyValues[item.ItemIndex - 1]["rID"].ToString();
          if (e.CommandName == RadGrid.FilterCommandName)
              RadGrid1.MasterTableView.GetColumn("UniqueName").Display = false;

Back to Top