Radgrid Get Selected Checkbox on postback

3 posts, 0 answers
  1. Roger
    Roger avatar
    10 posts
    Member since:
    Apr 2019

    Posted 01 Oct 2019 Link to this post

    I have a RadGrid in a user control on a webpage


    1. The radgrid has one template GridHyperLinkColumn and many other columns loaded from the datatable.

    2. The grid loads successfully from a Datatable with the template column.

    3. I have a Checkbox column and it shows well.

    4. Button click calls MarkSelectedInvalid()

    ** It never gets inside the For Loop as the RadGrid1.MasterTableView.Items is zero.  I have enabledviewstate on page, and in HTML Mark up for RadGrid.


    <telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="false" AllowMultiRowEdit = "true"
            SortingSettings-SortedBackColor="#999999" OnPreRender="RadGrid1_PreRender"
            CellSpacing="-1" GridLines="Both" Font-Size="xx-Small"
            EnableViewState="true" ViewStateMode="Enabled">
            <GroupingSettings CollapseAllTooltip="Collapse all groups" />
            <SortingSettings SortedBackColor="153, 153, 153" />
            <MasterTableView EditMode="InPlace" EnableColumnsViewState="true"
                <RowIndicatorColumn Visible="False">
                <ExpandCollapseColumn Created="True">
                    <telerik:GridHyperLinkColumn DataNavigateUrlFields="Path" DataTextField="Path"
                        FilterControlAltText="Filter Path column" HeaderText="Path"
                        SortExpression="Path" Target="_blank" UniqueName="Path1">




    private void MarkSelectedItemsInvalid()
               foreach (GridDataItem item in this.RadGrid1.MasterTableView.Items)
                   TableCell cell = item["MarkInvalid"];
                   CheckBox checkBox = (CheckBox)cell.Controls[0];
                   if (checkBox.Checked)
                       string path = (item["Path"].FindControl("TB_Path") as TextBox).Text;
                       string title = (item["Title"].FindControl("TB_Title") as TextBox).Text;
                       item.Enabled = false;
                       var dictionary = new Dictionary<string, string>();
                       dictionary.Add("ContentTypeId", GetContentTypeID(qsURLSite, GetLibraryFromURL(path), "Invalid"));
                       UpdateMetaData(path,GetLibraryFromURL(path), dictionary);
  2. Eyup
    Eyup avatar
    3962 posts

    Posted 04 Oct 2019 Link to this post

    Hi Roger,


    Your logic seems correct. Actually, this is probably related to the binding of the grid. Could you check whether you have DataBind() method for the grid in the code-behind and remove it?

    Feel free to give it a try and let me know about the outcome.


    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Roger
    Roger avatar
    10 posts
    Member since:
    Apr 2019

    Posted 04 Oct 2019 in reply to Eyup Link to this post

    I found my issue was with enableviewstate was set to false in a parent page. 


    It overrides the viewstate set on the control Its self.



Back to Top