This is a migrated thread and some comments may be shown as answers.

problem with setting selected row on Page_Load

2 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Murray
Top achievements
Rank 1
Murray asked on 18 Mar 2010, 03:04 AM
I'm trying to set selected row on Page_Load. The correct Page, total page and row count but no selected row?
I have the following:
// aspx page
...
<telerik:RadGrid
        ID="grdList" runat="server"
        EnableViewState="false"
        Height="328px"
        AllowPaging="true"
        AllowCustomPaging="true"
        AllowSorting="true"
        AllowFilteringByColumn="true"
        AutoGenerateColumns="False"
        PageSize="12"
        Skin="WebBlue">
...
// aspx.cs code behind page called from Page_Load
...
// this.pageSize is 12
// qmd.Count is 172
// this.PageIndex is 9
// rowIndex is 11
grdList.DataSource = qmarkRows;
grdList.VirtualItemCount = qmd.Count;
grdList.PageSize = this.pageSize;
grdList.CurrentPageIndex = qmd.PageIndex;
grdList.DataBind();
grdList.MasterTableView.Items[rowIndex].Selected = true;
...

What am i doing wrong?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Mar 2010, 06:09 AM

Hello Murray,

Try the your code for setting selected row, in PreRender event and see whether it helps.

C#:

 
    protected void RadGrid2_PreRender(object sender, EventArgs e)  
    {  
        if (!IsPostBack)  
        {  
            RadGrid2.PageSize = 12;  
            RadGrid2.CurrentPageIndex = 9;  
            RadGrid2.MasterTableView.Items[11].Selected = true;  
            RadGrid2.DataBind();  
        }  
    } 

-Shinu.

0
Murray
Top achievements
Rank 1
answered on 25 Mar 2010, 04:51 PM
Shinu,

Thanks that helped. What i ended up doing is getting/setting datasource in Page_Load and set selected row in GridID_PreRender

Murray
Tags
Grid
Asked by
Murray
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Murray
Top achievements
Rank 1
Share this question
or