This is a migrated thread and some comments may be shown as answers.
how to get radgrid prevous row's index id
1 Answer 38 Views
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 17 Feb 2013, 01:31 PM
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!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 18 Feb 2013, 06:32 AM
Hi,

Try the following code to achieve your scenario.
C#:
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;
      }
  }

Thanks,
Shinu.
Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or