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

SelectItems count is 0 after databind in response to an EditSelected Command

1 Answer 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 11 May 2012, 06:58 PM

I would like to click on my grid client select column, hit the edit button, and retain the checked/selected state of the item after postback, but for some reason the SelectItems count of the grid is 0 after databinding.

<Rad:RadGrid ID="testgrid"
OnNeedDataSource="testgrid_NeedDataSource"
ClientSettings-Selecting-AllowRowSelect="true"
 runat="server">
    <MasterTableView CommandItemDisplay="Top" EditMode="InPlace">
        <CommandItemTemplate>
            <Asp:LinkButton ID="btnEditSelected" runat="server"
                CommandName="EditSelected"
                EnableViewState="true"
                CausesValidation="false"
                Visible="true"
                Text="Edit"
            />
        </CommandItemTemplate>
        <Columns>
            <Rad:GridClientSelectColumn UniqueName="testselect">
            </Rad:GridClientSelectColumn>
        </Columns>
    </MasterTableView>
</Rad:RadGrid>
 
 
    protected void testgrid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        IList<string> items = new List<string>();
        items.Add("test");
        testgrid.DataSource = items;
    }

1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 13 May 2012, 07:13 AM
Hello Ryan,

Please look in below code snippet.

   
protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            foreach (GridEditableItem item in RadGrid1.EditItems)
            {
                item.Selected = true;
            }
        }
          

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or