Check a ClientSelectColumn in codebehind

5 posts, 1 answers
  1. Bruce
    Bruce avatar
    33 posts
    Member since:
    Oct 2006

    Posted 19 Mar 2009 Link to this post

     

    My aspx page has

        <telerik:GridClientSelectColumn Reorderable="False"  UniqueName="ClientSelectColumn">
                  <HeaderStyle Width="20px"></HeaderStyle>
        </telerik:GridClientSelectColumn>
     

    In my code behind, I want to initialy check some rows.  How do I code this?

    The following code does not produce an error, but nothing is checed when the page is displayed
    (I've tried this the following events: ItemDataBound, ItemCommand, and PreRender

        Dim chkClientSelectColumn As CheckBox = DirectCast(item.FindControl("ClientSelectColumnSelectCheckBox"), CheckBox)
        chkClientSelectColumn.Checked = True



  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Mar 2009 Link to this post

    Hi Bruce,

    Try the following code snippets for selecting the rows fom code behind based on a condition.

    VB:
    Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) 
        If TypeOf e.Item Is GridDataItem Then 
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) 
            If item("CategoryID").Text = "1" Then 
                ' Check for the condition 
                item.Selected = True 
            End If 
        End If 
    End Sub 

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bruce
    Bruce avatar
    33 posts
    Member since:
    Oct 2006

    Posted 20 Mar 2009 Link to this post

    I'm not trying to see which rows are selected, I'm trying to set a row to being selected
  5. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 23 Mar 2009 Link to this post

    Hello Bruce,

    I believe that the code snippet, provided by Shinu will be working as expected. You can also select an item of your choice  (together with the checkbox) as shown below:
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
        RadGrid1.MasterTableView.Items(2).Selected = True 
    End Sub 

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Bruce
    Bruce avatar
    33 posts
    Member since:
    Oct 2006

    Posted 23 Mar 2009 Link to this post

    Thanks - just what I was looking for.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017