How to do the client side validation for Checkbox?

6 posts, 0 answers
  1. sharath
    sharath avatar
    12 posts
    Member since:
    Aug 2014

    Posted 22 Jan 2015 Link to this post

    Hello Admins,

    I'm having a location grid user control. Each grid item contains check boxes. I can select the multiple check boxes  and delete all at once when i click on the link button which i have defined. Everything is working fine. But, if i don't select any of the checkboxes to delete or there is no data in the grid, how to do the client side validation for this scenario. Please help me in this regard.

    And also whenever i select any check boxes, post back is happening. How to overcome this problem as well.

    My checkbox code:
       <telerik:GridTemplateColumn UniqueName="CheckboxId"  HeaderText="View"  DataField="View" > 
                                 <ItemTemplate> 
                                     <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"/>  
                                </ItemTemplate> 
                              </telerik:GridTemplateColumn>

    My checkbox code behind:

    foreach (GridDataItem item in rgLocations.MasterTableView.Items)
                    {
                        
                        chk = (CheckBox)item.FindControl("CheckBox1");
                        if (!chk.Checked)
                        {
                            DataRow newRowAdd = myDataTable.NewRow();
                            newRowAdd["Id"] = item["Id"].Text;
                            newRowAdd["Name"] = item["Name"].Text;
                            newRowAdd["CTID"] = item["CTID"].Text;
                            myDataTable.Rows.Add(newRowAdd);
                            myDataTable.AcceptChanges();
                        }
                    }
                    rgLocations.DataSource = myDataTable.DefaultView;
                    rgLocations.Rebind();

    My link button code:
    <asp:LinkButton ID="lnkDeleteLoc" runat="server" OnClick="lnkDeleteLoc_Click">Delete the Location(s)</asp:LinkButton>
  2. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 27 Jan 2015 Link to this post

    Hi Sharath,

    I've created a sample RadGrid web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. sharath
    sharath avatar
    12 posts
    Member since:
    Aug 2014

    Posted 27 Jan 2015 in reply to Eyup Link to this post

    Thanks a lot for answering for my query. Is it possible to display something saying users that "You have not slected any checkbox to delete" when no check boxes has been selected and "There is no location added to the grid" when user tried to delete empty grid in the Java script itself instead of returning true or false. 

    Regards,
    Sharath
  5. sharath
    sharath avatar
    12 posts
    Member since:
    Aug 2014

    Posted 29 Jan 2015 in reply to Eyup Link to this post

    Hello Eyup, could you please shed some idea for me. I'm getting JS error in browser saying that "grid.get_masterTableView().get_dataItems()" is null when i try to press delete when the grid is empty. How to overcome this problem.
  6. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 30 Jan 2015 Link to this post

    Hi Sharath,

    I will check the mentioned scenario and let you know when ready.

    Thank you for your patience in advance.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 05 Feb 2015 Link to this post

    Hello Sharath,

    Thank you again for your patience.

    I'm sending the modified version of the sample with the requested implementation.

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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