I am using the SetCurrent and SetSelected methods of the Record property to select the second row of the grid. The initial page loads and the second record is selected properly but when I select another page then the selected row is always the first one, not the second (or third, etc). I am using EnsureSelection of the GridGroupingControl but it seems like this is a feature/issue of the paging control since it only affects paged requests so I played with SetPagingParameters (of the GridPager) to set the StartRowIndex to 2 but that did not work either. How do I select a different row other than the first one on a new page? I need to do this dynamically, really. In other words, if I can set it to row 2 I will need to be able to set any row for my production task.
Here is my code:
ASPX:
<syncfusion:GridGroupingControl ID="MainGrid" runat="server"
ViewStateMode="Enabled"
ClientObjectID="__essentialGrid"
AutoFormat="Office 2007 Blue"
DataSourceCachingMode="None" >
</syncfusion:GridGroupingControl>
<syncfusion:GridPager ID="MainGridPager" runat="server" Width="715px" PagingControlID="MainGrid" PageSize="12" ViewStateMode="Enabled" Skin = "Office2007Blue" >
<PagerItems>
<syncfusion:NextPreviousGridPagerItem ShowFirstPageButton="true" ShowPreviousPageButton="true"
ShowLastPageButton="False" ShowNextPageButton="false" />
<syncfusion:NumericGridPagerItem ButtonCount="7" />
<syncfusion:NextPreviousGridPagerItem ShowFirstPageButton="false" ShowPreviousPageButton="false"
ShowLastPageButton="true" ShowNextPageButton="true" />
</PagerItems>
</syncfusion:GridPager>
CS (code-behind):
protected void Page_Load(object sender, EventArgs e)
{
MainGrid.DataSource = GetData();
MainGrid.EnsureSelection = false;
//int recordIndex = ((MainGrid.CurrentPage - 1) * MainGridPager.MaximumRows) + 2;
int recordIndex = 2;
if (IsPostBack)
{
recordIndex = 15;
}
MainGrid.Table.Records[recordIndex].SetCurrent();
MainGrid.Table.Records[recordIndex].SetSelected(true);
}
private List<CostItem> GetData()
{
..
(returns 103 items)
..
}