how to add checkbox column in radgrid

8 posts, 0 answers
  1. yogesh
    yogesh avatar
    16 posts
    Member since:
    Feb 2011

    Posted 28 Feb 2011 Link to this post

    HI,
          I am yogesh. i am working with asp.net ajax rad grid. i need to add checkbox column programmatically and should be able to select multiple rows and export to excel...could anyone help me out plz....its urgent(asp.net with c# code)
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 28 Feb 2011 Link to this post

    hi yogesh,
    code for add checkbox column programmatically

     GridClientSelectColumn objGridClientSelectColumn = new GridClientSelectColumn();
     objGridClientSelectColumn.UniqueName = "UniqueName";
     rgTableLibrary.MasterTableView.Columns.Add(objGridClientSelectColumn);

    plz set AllowMultiRowSelection="true"

    for more help of dynamic creation of column http://demos.telerik.com/aspnet-ajax/grid/examples/programming/groupby/defaultcs.aspx
    for export http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx

    Thanks,
    Jayesh Goyani

                   
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. yogesh
    yogesh avatar
    16 posts
    Member since:
    Feb 2011

    Posted 28 Feb 2011 Link to this post

    Thanks a lot jayesh..its working fine. now i have an issue like..." I should export the row of radgrid which i have checked in the checkbox column to pdf,excel,word...colud you plz send me the code...it should allow multi row selection also.


    Thankyou,


    Regards,
    yogesh
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 01 Mar 2011 Link to this post

    hi yogesh,

    for export seleted rows....
    foreach (GridItem item in radgrdExtraActivity.MasterTableView.GetItems(new GridItemType[] { GridItemType.Item, GridItemType.AlternatingItem }))
            {
                GridDataItem dataitem = (GridDataItem)item;
                TableCell cell = dataitem["ClientSelectColumn"];
                CheckBox checkBox = (CheckBox)cell.Controls[0];
                if (!checkBox.Checked)
                {
                    dataitem.Dispose();
                }
                 
            }
     
     radgrdExtraActivity.MasterTableView.ExportToExcel();

    <telerik:RadGrid ID="radgrdExtraActivity" runat="server" AllowMultiRowSelection="true">
     <MasterTableView>
     <Columns>
                             <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
     </Columns>
     </MasterTableView>
    </telerik:RadGrid>

    Thanks,
    Jayesh Goyani
  6. K
    K avatar
    1 posts
    Member since:
    May 2011

    Posted 09 May 2011 Link to this post

    I have a Rad grid with a check box column which I have set AutoPostBack to true cause I when the checkbox is clicked I want to save some values into the database however the onCheckedChanged event is not fired when I click on the checkbox. I need to get this done asap so any help is appreciated. Thanks.
  7. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 11 May 2011 Link to this post

    Hi k,

    <MasterTableView DataKeyNames="ActionMenuID">
                              
                                <Columns>
                                  
                                    <telerik:GridTemplateColumn>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkTest" runat="server" AutoPostBack="true" OnCheckedChanged="chkTest_CheckedChanged" />
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
      </Columns>
    protected void chkTest_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox chkTest = sender as CheckBox;
            GridDataItem item = (GridDataItem)chkTest.NamingContainer;
            string s1 = item.GetDataKeyValue("ActionMenuID").ToString();
            // your DB insert shold be here
        }

    Thanks,
    Jayesh Goyani
  8. Brijesh Gadhiya
    Brijesh Gadhiya avatar
    7 posts
    Member since:
    Sep 2009

    Posted 09 Aug 2013 Link to this post

    Awesome!
    That was exactly what I was looking for.
  9. Meenakshi
    Meenakshi avatar
    3 posts
    Member since:
    Oct 2015

    Posted 29 Oct 2015 Link to this post

    I placed checkbox as templatecolumn and I want to show the 1 or 0 values on the checkbox in pageload. Also want to check and value and store the checkbox value in database. Could you please help me in this regard.

      <telerik:GridTemplateColumn HeaderText="IsActive" UniqueName="IsActive">
                    <ItemTemplate>
                    <asp:CheckBox ID="chkActive"  runat="server" AutoPostBack="true" Visible="true" />
                    </ItemTemplate>
                    </telerik:GridTemplateColumn>

    Active datafield hold 1/0 in database and need to show the value of checkbox when page is loading on the Radgrid.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017