I am creating one entry screen using RadGrid in Batch Edit Mode. My Grid is having mainly some columns of ComboBox (rdcombPayCodeNm) and TextBox ("txtHours" or "txtAmount"). I have added attribute like "PaidInAmount"/"PaidInHours" in RadCombo in PageLoad. I want to verify textBox value based on user selected item and their attribut value of ComboBox. Suppose user selected one item in combo and their attribute value is "PaidInAmount" then user should not enter any value in "txtHours" textbox and opposite if user selected combobox attribute is "PaidInHours" then there should be any value in "txtAmount" textbox. There would be multiple row in grid and I have to validate one by one row and show message to user. I want to perform this operation in client side as I can't read grid value in server side in BatchEdit mode.
I am copying my aspx code and code behind for your ref.
ASPX
------------------------------------------------------------------
<telerik:RadGrid ID="rdgvOtherPay" runat="server" AllowAutomaticInserts="True" AllowAutomaticUpdates="true" AllowMultiRowEdit="true" AllowPaging="True"
AutoGenerateColumns="False" CellSpacing="0" OnNeedDataSource="rdgvOtherPay_NeedDataSource"
GridLines="None"
PageSize="12" AllowMultiRowSelection="true">
<ClientSettings>
<ClientEvents OnBatchEditSetEditorValue="setEditorValue" OnRowCreated="rowCreated" OnBatchEditOpened="editOpened" />
</ClientSettings>
<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText=""
CommandItemSettings-CancelChangesText="" CommandItemSettings-RefreshText="" CommandItemSettings-ShowRefreshButton="false"
CommandItemSettings-ShowSaveChangesButton="false" CommandItemSettings-ShowCancelChangesButton="false" DataKeyNames="idEmpOtherPay"
Dir="rtl" EditMode="Batch" HorizontalAlign="NotSet" InsertItemDisplay="Bottom">
<BatchEditingSettings EditType="Row" />
<SortExpressions>
<telerik:GridSortExpression FieldName="idEmpOtherPay" SortOrder="Descending" />
</SortExpressions>
<Columns>
<telerik:GridTemplateColumn DataField="PayCodeId" HeaderStyle-Width="110px" HeaderText="Pay Code" UniqueName="PayCodeId">
<ItemTemplate>
<%# Eval("PayCodeName") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="rdcombPayCodeNm" runat="server" class="TelerikDrop" dir="ltr" DropDownAutoWidth="Enabled" Filter="StartsWith" TabIndex="8"
>
<Items>
<telerik:RadComboBoxItem Text="PayCodeName1" />
<telerik:RadComboBoxItem Text="PayCodeName2" />
</Items>
</telerik:RadComboBox>
<span style="color: red; font-size: larger; vertical-align: bottom">
</span>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="OtherHours" HeaderStyle-Width="90px" HeaderText="Hours" UniqueName="OtherHours">
<ItemTemplate>
<asp:Label runat="server" ID="lblOtherHours" Text='<%# Eval("OtherHours") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox ID="txtHours" runat="server" MaxLength="15" Width="80%">
<NumberFormat DecimalDigits="2" GroupSeparator="" />
</telerik:RadNumericTextBox>
<%--<ajax:popupcontrolextender id="PopupControlExtender1" runat="server" popupcontrolid="Panel1" position="Bottom" targetcontrolid="txtHours" />--%>
<span style="color: red; font-size: larger; vertical-align: bottom">
</span>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="OtherAmount" HeaderStyle-Width="90px" HeaderText="Amount" UniqueName="OtherAmount">
<ItemTemplate>
<%# Convert.ToDouble(Eval("OtherAmount")).ToString("0.00") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox ID="txtAmount" runat="server" MaxLength="15" Width="80%">
<NumberFormat DecimalDigits="2" GroupSeparator="" />
</telerik:RadNumericTextBox>
<span style="color: red; font-size: larger; vertical-align: bottom"></span>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridButtonColumn ConfirmText="Delete Other Earnings?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
</telerik:GridButtonColumn>
</Columns>
<PagerStyle Mode="NumericPages" ShowPagerText="False" />
</MasterTableView>
</telerik:RadGrid>
Code Behind-
foreach (PayCodeDO _row in payCodeList)
{
RadComboBoxItem item = new RadComboBoxItem
{
Value = _row.PayCodeId.ToString() + " " + _row.Description,
Text = _row.Description,
};
// string noOfHours = Convert.ToString(_row.PaidInAmount);
item.Attributes.Add("PaidInAmount", _row.PaidInAmount);
item.Attributes.Add("PaidInHours", _row.PaidInHours);
item.Attributes.Add("PaidInHrAndAm", _row.PaidInHourseAndAmount);
payCodeCombo.Items.Add(item);
}
payCodeCombo.Items.Insert(0, new RadComboBoxItem(""));
Thank in Advance.
Regards,
Anil