Grid Client Select Column Select Checkbox from Server Side.

6 posts, 0 answers
  1. sweta
    sweta avatar
    21 posts
    Member since:
    Jun 2010

    Posted 28 Oct 2010 Link to this post


    Hi,

    i'm using latest version of telerik.web.dll. we have used rad grid control in many of our pages. we have used GridClientSelect Column for the selection of rows. suppose i have parent page and child page. my child page contains radgrid( with GridclinetSelect Column).
    i select some rows from child page and click the save button. my selected records are populated in my parent page. now i again open the child page. we want to show the user which rows the user has selected previously. but i'm not able to select the checkboxes from server side. is there anyother way so that i can display the selected rows again when i open the child page by displaying the selected checkboxes. i want to show the selected rows based on my datakey values.

    please suggest some solution.

    Thanks
    Sweta
  2. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 28 Oct 2010 Link to this post

    Hello Sweta,

    Please use the approach from the Client-Side Row Selection Persisted With Paging code library in order to implement the desired functionality.

    I hope this helps.

    Regards,
    Mira
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. zAxis
    zAxis avatar
    13 posts
    Member since:
    Aug 2010

    Posted 03 Apr 2012 Link to this post

    You can check the GridClientSelectColumn from server-side like this.

    Private Sub SelectGridRow()
       For Each dataItem As GridDataItem In rgRMR.MasterTableView.Items
          Dim vals As New Hashtable
          dataItem.ExtractValues(vals)
          If vals("RMRID") = r.RMRID Then
             Dim cb As CheckBox = CType(dataItem.FindControl("ClientSelectColumnSelectCheckBox"), CheckBox)
             cb.Checked = True
             dataItem.Selected = True
          End If
       Next
    End Sub
  4. Gaurav
    Gaurav avatar
    6 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    Dear All,

    Please help me I am really struggling with accessing the GridClientSelectColumn at server side. My problem is as follows:

    I have a RadGrid that has the following structure:

    <Telerik:RadGrid ID="rgdPagePromotion" runat="server" AutoGenerateColumns="false"

     AllowAutomaticInserts="false" AllowMultiRowSelection="true" OnItemCreated="rgdPagePromotion_ItemCreated">

    <PagerStyle Mode="NumericPages"></PagerStyle>

    <MasterTableView AutoGenerateColumns="False" DataKeyNames="Publication">

      <Columns>

    <Telerik:GridBoundColumn HeaderText="Publication Code" DataField="Publication"

                             ReadOnly="true" Visible="true" UniqueName="Publication Code" >

                            </Telerik:GridBoundColumn>

                                               

                            <Telerik:GridClientSelectColumn HeaderText="Promote" DataTextField="Promote" UniqueName="Promote"  >
         </Telerik:GridClientSelectColumn>

                            
                           <Telerik:GridImageColumn HeaderText="Status" ImageUrl=""

                            AlternateText="Not Yet started to Promote">

                           </Telerik:GridImageColumn>

           </Columns>

            </MasterTableView>

            
            <ClientSettings EnableRowHoverStyle="false" >

    <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true"></Selecting>

            </ClientSettings>

     </Telerik:RadGrid>


    As you can see from above I am using a GridClientSelectColumn for having a checkbox column, with a header checkbox to select all checkboxes, in the radgrid. Now the problem is when the Radgrid is initially databinded on server side I wish to set some checkboxes. Then on the client side the user may make select/unselect the checkboxes. There is a separate button on the page on click of which, on postback, on server side again I need to access this GridClientSelectColumn to see which checkboxes are selected. 

    I have read the article on 
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx

    which describes something similar but they are using asp:checkboxes which I somehow do not wish to use due to some reason.  


    On server side on page load immediately after 
                rgdPagePromotion.DataSource = dt;
                rgdPagePromotion.DataBind();

     I did try to access the column by the following code but it didn't work:

                foreach (GridDataItem item in rgdPagePromotion.MasterTableView.Items)
                {
                    CheckBox cb = (CheckBox)item["Promote"].Controls[0];
                    cb.Checked = true;
                }

    The code shows no error but on client side the checkboxes are not checked. 

    Could someone please help me with some code examples about how to access the gridClientSelectColumn checkboxes at server side during initial page load and then again on button click postback. 

    Waiting eagerly for a response. 

    Thanks and Regards,
    Gaurav

  5. Gaurav
    Gaurav avatar
    6 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    Dear All,

    Please help me I am really struggling with accessing the GridClientSelectColumn at server side. My problem is as follows:

    I have a RadGrid that has the following structure:

    <Telerik:RadGrid ID="rgdPagePromotion" runat="server" AutoGenerateColumns="false"

     AllowAutomaticInserts="false" AllowMultiRowSelection="true"OnItemCreated="rgdPagePromotion_ItemCreated">

    <PagerStyle Mode="NumericPages"></PagerStyle>

    <MasterTableView AutoGenerateColumns="False" DataKeyNames="Publication">

      <Columns>

    <Telerik:GridBoundColumn HeaderText="Publication Code"DataField="Publication"

                             ReadOnly="true" Visible="true" UniqueName="Publication Code" >

                            </Telerik:GridBoundColumn>

                                               

                            <Telerik:GridClientSelectColumn HeaderText="Promote"DataTextField="Promote" UniqueName="Promote"  >
         </Telerik:GridClientSelectColumn>

                            
                           <Telerik:GridImageColumn HeaderText="Status" ImageUrl=""

                            AlternateText="Not Yet started to Promote">

                           </Telerik:GridImageColumn>

           </Columns>

            </MasterTableView>

            
            <ClientSettings EnableRowHoverStyle="false" >

    <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true"></Selecting>

            </ClientSettings>

     </Telerik:RadGrid>


    As you can see from above I am using a GridClientSelectColumn for having a checkbox column, with a header checkbox to select all checkboxes, in the radgrid. Now the problem is when the Radgrid is initially databinded on server side I wish to set some checkboxes. Then on the client side the user may make select/unselect the checkboxes. There is a separate button on the page on click of which, on postback, on server side again I need to access this GridClientSelectColumn to see which checkboxes are selected. 

    I have read the article on 
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx

    which describes something similar but they are using asp:checkboxes which I somehow do not wish to use due to some reason.  


    On server side on page load immediately after 
                rgdPagePromotion.DataSource = dt;
                rgdPagePromotion.DataBind();

     I did try to access the column by the following code but it didn't work:

                foreach (GridDataItem item in rgdPagePromotion.MasterTableView.Items)
                {
                    CheckBox cb = (CheckBox)item["Promote"].Controls[0];
                    cb.Checked = true;
                }

    The code shows no error but on client side the checkboxes are not checked. 

    Could someone please help me with some code examples about how to access the gridClientSelectColumn checkboxes at server side during initial page load and then again on button click postback. 

    Waiting eagerly for a response. 

    Thanks and Regards,
    Gaurav

  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Feb 2013 Link to this post

    Hi,

    Please try the following code snippet to access the ClientSelectColumn in code behind.

    For accessing the ClientSelectColumn in PageLoad and Checking them for the First time.
    C#:
    protected void rgdPagePromotion_PreRender(object sender, EventArgs e)
    {
        // For Checking CheckBox Column for time first time on Pageload
        if (!IsPostBack)
        {
            foreach (GridDataItem item in rgdPagePromotion.MasterTableView.Items)
            {
                CheckBox cb = (CheckBox)item["Promote"].Controls[0];
                cb.Checked = true;
                item.Selected = true;
            }
        }
    }

    For accessing ClientSelectColumn and checking it on Button Click event.
    C#:
    protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (GridDataItem item in rgdPagePromotion.MasterTableView.Items)
        {
            CheckBox CheckBox1= (CheckBox)item["Promote"].Controls[0];
            CheckBox1.Checked = true;
            item.Selected = true;
        }
    }

    Thanks,
    Shinu.
Back to Top