Hello, Telerik Team
I was using telerik:RadGrid control and grid ItemTemplate bind radbutton with toggletype set to checkbox and buttontype as standard button,
this is bind properly well and displayed data is good, but when I am check if at least one selected checkbox in grid on click on save data, I was only client side checking and using JavaScript currently I find your telerik forum code but they are not working ,Please help to me
Thanks
Jyosana
I was using telerik:RadGrid control and grid ItemTemplate bind radbutton with toggletype set to checkbox and buttontype as standard button,
this is bind properly well and displayed data is good, but when I am check if at least one selected checkbox in grid on click on save data, I was only client side checking and using JavaScript currently I find your telerik forum code but they are not working ,Please help to me
Thanks
Jyosana
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/PMMain.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ArchonixXJailProgramManagement.ProgramManagement.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"AdminContentPlaceHolder"
runat
=
"server"
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel"
runat
=
"server"
Width
=
"100%"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock2"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function ValidateCheckBox(sender, eventArgs) {
var TargetBaseControl = document.getElementById('<%= grdScheduler.ClientID%>');
var TargetChildControl = "btnToggle";
var Inputs = TargetBaseControl.getElementsByTagName("input");
var postback = false;
for (var n = 0; n <
Inputs.length
; ++n) {
if (Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl, 0) >= 0) {
if (Inputs[n].checked) {
postback = true;
break;
}
}
}
sender.set_autoPostBack(postback);
if (!postback) {
alert('Please select atleast one checkbox record!');
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxPanel
ID
=
"radSSNSearch"
runat
=
"server"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
div
class
=
"program_container"
>
<
fieldset
>
<
legend
>Scheduler Class </
legend
>
<
table
id
=
"Table2"
align
=
"center"
runat
=
"server"
cellspacing
=
"0"
cellpadding
=
"4"
style
=
"width: 98%; height: 100%; vertical-align: top"
>
<
tr
>
<
td
colspan
=
"2"
>
<
telerik:RadGrid
ID
=
"grdScheduler"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
AllowAutomaticDeletes
=
"false"
AllowAutomaticUpdates
=
"false"
OnNeedDataSource
=
"grdScheduler_NeedDataSource"
OnItemDataBound
=
"grdScheduler_ItemDataBound"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
MasterTableView
Width
=
"100%"
CommandItemDisplay
=
"None"
ClientDataKeyNames
=
"SchedulePK"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"false"
/>
<
Columns
>
<
telerik:GridTemplateColumn
HeaderText
=
"Enroll"
>
<
ItemTemplate
>
<
telerik:RadButton
ID
=
"btnToggle"
runat
=
"server"
Width
=
"17px"
ToggleType
=
"CheckBox"
Checked='<%# Convert.ToBoolean(Eval("Enroll")) %>' ButtonType="StandardButton"
CommandArgument='<%# Eval("ScheduleClassPK") %>' AutoPostBack="false">
<
ToggleStates
>
<
telerik:RadButtonToggleState
PrimaryIconCssClass
=
"rbToggleCheckboxChecked"
/>
<
telerik:RadButtonToggleState
PrimaryIconCssClass
=
"rbToggleCheckbox"
/>
</
ToggleStates
>
</
telerik:RadButton
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Class Name"
SortExpression
=
"ClassName"
UniqueName
=
"ClassName"
DataField
=
"ClassName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Description"
SortExpression
=
"Description"
UniqueName
=
"Description"
DataField
=
"Description"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Location"
SortExpression
=
"LocationCode"
UniqueName
=
"LocationCode"
DataField
=
"LocationCode"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
AlternatingItemStyle
HorizontalAlign
=
"Left"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
<
telerik:RadButton
ID
=
"btnSave"
runat
=
"server"
OnClick
=
"btnSave_Click"
AutoPostBack
=
"false"
OnClientClicked
=
"ValidateCheckBox"
Text
=
"Save"
>
</
telerik:RadButton
>
</
td
>
</
tr
>
</
table
>
</
fieldset
>
</
div
>
</
telerik:RadAjaxPanel
>
</
asp:Content
>