Reylin Mathew

Reylin Mathew

  • NA
  • 347
  • 76k

how to validation usng select only 1 radio btn in inner grid

Jul 3 2018 2:15 AM
i need valdation used for inner grid and also select only one radio button.i got select only one radio button using inner grid.
 
but validation is not working . i want error msg disply on button click ie (their is no radio button select and button click ) ..plz help me ...thnkx in adv
  1. <html xmlns="http://www.w3.org/1999/xhtml">  
  2. <head runat="server">  
  3. <title></title>  
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>  
  5. <script language="javascript" type="text/javascript">  
  6. function singleRbtnSelect(chb) { //code for select only one radio button  
  7. $(chb).closest("table").find("input:radio").prop("checked"false).change();  
  8. $(chb).prop("checked"true);  
  9. }  
  10. </script>  
  11. <style type="text/css">  
  12. .auto-style1 {  
  13. width: 104px;  
  14. }  
  15. </style>  
  16. </head>  
  17. <body>  
  18. <form id="form1" runat="server">  
  19. <div>  
  20. <br />  
  21. <br />  
  22. <asp:Panel ID="pnlRegister" runat="server">  
  23. <center> <table border="1">  
  24. <tr>  
  25. <td class="auto-style1">REGISTER NO</td>  
  26. <td><asp:TextBox ID="txtRegisterNo" runat="server"></asp:TextBox></td>  
  27. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter Your Register Number" ControlToValidate="txtRegisterNo"></asp:RequiredFieldValidator>  
  28. </tr>  
  29. <tr><td class="auto-style1"> <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click1" Width="76px" />  
  30. <asp:Label ID="lblErr" runat="server"></asp:Label>  
  31. </td></tr>  
  32. </table></center>  
  33. </asp:Panel>  
  34. <asp:Panel ID="pnlElection" runat="server">  
  35. <center> <table border="1">  
  36. <tr>  
  37. <td>STUDENT NAME:</td>  
  38. <td><asp:Label ID="lblStdName" runat="server"></asp:Label></td>  
  39. </tr>  
  40. <tr>  
  41. <td>BATCH NAME:</td>  
  42. <td><asp:Label ID="lblbatch" runat="server"></asp:Label></td>  
  43. </tr>  
  44. </table>  
  45. </center>  
  46. <br />  
  47. <center>  
  48. <asp:GridView ID="gdPosition" runat="server" AutoGenerateColumns="False" DataKeyNames="Pid" OnRowDataBound="gdPosition_RowDataBound" style="width:300px">  
  49. <Columns>  
  50. <asp:TemplateField >  
  51. <ItemTemplate>  
  52. <center> <asp:Label ID="lblPosition" runat="server" Text='<%# Eval("Vote") %>'></asp:Label></center>  
  53. <asp:HiddenField ID="hdfPosition" runat="server" />  
  54. <asp:GridView ID="gdElection" runat="server" AutoGenerateColumns="False" DataKeyNames="Position" style="width:300px">  
  55. <Columns>  
  56. <asp:TemplateField>  
  57. <ItemTemplate>  
  58. <center><asp:Label ID="Label1" runat="server" Text='<%# Eval("StdName") %>'></asp:Label></center>  
  59. </ItemTemplate>  
  60. </asp:TemplateField>  
  61. <asp:TemplateField HeaderText="Vote For">  
  62. <ItemTemplate>  
  63. <%--<asp:RadioButton ID="rbVoteFor" runat="server" Text='<%#Eval("Pid") %>' /> onclick="singleRbtnSelect(this);"--%>  
  64. <center> <asp:RadioButton id="rdVote" runat="server" AutoPostBack="true" OnClick="javascript:SelectSingleRadiobutton(this.id)" GroupName="Position" /></center>  
  65. <asp:HiddenField ID="hdfVid" runat="server" Value='<%#Eval("Position")%>' />  
  66. <%--OnCheckedChanged="rdVote_CheckedChanged"--%>  
  67. </ItemTemplate>  
  68. </asp:TemplateField>  
  69. </Columns>  
  70. </asp:GridView>  
  71. </ItemTemplate>  
  72. </asp:TemplateField>  
  73. </Columns>  
  74. </asp:GridView>  
  75. </center>  
  76. <br />  
  77. <center> <asp:Button ID="btnVote" runat="server" Text="Vote" OnClick="btnVote_Click" />  
  78. <asp:Label ID="lblError" runat="server"></asp:Label></center>  
  79. </asp:Panel>  
  80. </div>  
  81. </form>  
  82. </body>  
  83. </html>

Answers (3)