Loading ...

Validate checkbox and textbox inside a gridview through Jquery?

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  client side web development   » Validate checkbox and textbox inside a gridview through Jquery?

Validate checkbox and textbox inside a gridview through Jquery?

Posts under the topic: Validate checkbox and textbox inside a gridview through Jquery?

Posted: 4/21/2011

Starter 1414  points  Starter
  • Joined on: 12/1/2008
  • Posts: 66

I have a gridview which contains few columns. There is 1 checkbox "Select" column  in that gird. Next, to that column there is 1 more column " DPC Sections" which is actually a gridview inside the main gridview with checkbox and textbox.

On click of Save button, I want to check if the "Select" column checkbox is checked then at least 1 "DPC Sections" corresponding to that row should be checked as well. When "DPC Sections" are checked then textboxes corresponding to them should not be empty.

So I want to implement 3 validations. I hope you will be able to understand what I want to do.

 

           <table cellspacing="0" cellpadding="5" rules="all" border="0" id="pagetitle">
                <tr>
                    <td align="center">
                      <asp:GridView ID="grdStateOffices" runat="server" AutoGenerateColumns="False" Width="85%"
                            AllowPaging="True" DataKeyNames="AuditeeOfficeId"  PageSize="10" 
                            OnRowDataBound="grdStateOffices_RowDataBound" 
                            onpageindexchanging="grdStateOffices_PageIndexChanging">
                            <Columns>
                                <asp:TemplateField HeaderText="S.No.">
                                    <ItemTemplate>
                                        <asp:Label ID="Sno" runat="server" Text="<%# Container.DataItemIndex+1 %>"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField HeaderText="Office" DataField="AuditeeOfficeName" />
                                <asp:BoundField HeaderText="Parent Office" DataField="ParentOfficename" />
                                <asp:BoundField HeaderText="Department" DataField="DepartmentName"  />
                                <asp:BoundField HeaderText="Type of Organization" DataField="TypeOfOrganization" />
                                <asp:BoundField HeaderText="Organization Name" DataField="OrganizationName" />
                                <asp:BoundField HeaderText="Office Type" DataField="OfficeType" />
                                <asp:TemplateField HeaderText="Select" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkBxSelect" runat="server" />
                                         <asp:HiddenField ID="hdnSavedFlag" Value='<%# Eval("SavedFlag") %>' runat="server" />
                                       <asp:HiddenField ID="hdnNewSavedFlag" Value='<%# Eval("SavedFlag") %>' runat="server" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                      <asp:TemplateField HeaderText="DPC Sections" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:GridView ID="grdDPCSections" runat="server" ShowHeader="False" DataKeyNames="SectionID" >
                                           <Columns>
                                            <asp:TemplateField HeaderStyle-HorizontalAlign="Center">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblDpcSectionID" runat="server" Text='<%# Eval("SectionID") %>'  Visible="false"   ></asp:Label>
                                                    <asp:CheckBox ID="chkDPCSections" runat="server" Text ='<%# Eval("SectionName") %>'  />
                                                    <asp:HiddenField ID="hdnDPCSavedFlag" Value='<%# Eval("Action") %>' runat="server" />
                                                    <asp:HiddenField ID="hdnDPCNewSavedFlag" Value='<%# Eval("Action") %>' runat="server" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:TextBox ID="txtDays" runat="server" MaxLength="10" Width="100px" AutoComplete="Off"></asp:TextBox>
                                                    <asp:FilteredTextBoxExtender ID="fltrTextbox" runat="server" TargetControlID="txtDays" FilterType="Numbers"></asp:FilteredTextBoxExtender>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                       
                                           </Columns>
                                        </asp:GridView>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Mapped Auditor Org Unit" Visible="false">
                                    <ItemTemplate>
                                      
                                       <asp:HiddenField ID="hdnAuditorOrgUnitID" Value='<%# Eval("MappedAuditorOrgUnitID") %>' runat="server" />
                                       <asp:Label ID="lblAuditorName" runat="server" Text='<%# Eval("AuditeeOrgUnitName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>     

 

Please refer to the below screen shot.


Posted: 4/21/2011

Guru 16773  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490

Please provide a sample code for your grid with dummy data to fill the grid so that we don't have to create a sample from scratch.


tags C#

Posted: 4/21/2011

Starter 1414  points  Starter
  • Joined on: 12/1/2008
  • Posts: 66

Raghav Khunger said:

Please provide a sample code for your grid with dummy data to fill the grid so that we don't have to create a sample from scratch.

Hi,

I've attached the sample code.

Thanks,

Sumit


Posted: 4/21/2011

Guru 16773  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490

Raghav Khunger said:

with dummy data to fill the grid




Page 1 of 1 (4 items)