sql - Textboxes inside gridview validation -


i have gridview in have 100 rows of textboxes. textboxes have same id 'txtempcode'. user enters data in rows of gridview. how validate textboxes such 1 employee code entered once in textboxes. avoid duplicate entry of data. suppose user enters employee code '1234', should not allowed in other rows of textboxes. if enter, message should appear 'employee code has been entered'.

can tell how achieve this?

<asp:gridview id="gridview2" runat="server" style="margin-left: 23px; margin-top: 11px;" width="420px" cellpadding="4" autogeneratecolumns="false" forecolor="#333333" gridlines="none" height="213px"  >                 <alternatingrowstyle backcolor="white" />               <columns>                               <asp:templatefield headertext="employee code">              <itemtemplate>                  <asp:textbox id="txtempcode" runat="server" ontextchanged="txtid_textchanged" autopostback ="true"   ></asp:textbox>                </itemtemplate>

you can use logic of per requirement.

<head>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> </head>  <script>      function isvalidtest(control) {          name = control.name;          var list = document.getelementbyid("txtempcode");          var contents = $("[id=txtempcode]");          var textboxid = name;          var txtbox = document.getelementsbyname(name);         var textboxvalue = txtbox[0].value;          (i = 0; < contents.length; i++)          {               var currenttextboxname=contents[i].name;             var currenttextboxvalue=contents[i].value;               //compare changed value existing values in other textboxes             if (name != currenttextboxname && currenttextboxvalue == textboxvalue)             {                 alert('employee code has been entered');                 txtbox[0].value = '';                  return false;             }                 }          return true;     }  </script>      <div>         <asp:gridview id="gridview2" runat="server" style="margin-left: 23px; margin-top: 11px;"             width="420px" cellpadding="4" autogeneratecolumns="false" forecolor="#333333"             gridlines="none" height="213px">             <alternatingrowstyle backcolor="white" />             <columns>                 <asp:templatefield headertext="employee code">                     <itemtemplate>                         <asp:textbox id="txtempcode" runat="server"  autopostback="true" clientidmode="static" onchange="javascript: return isvalidtest(this);"></asp:textbox>                     </itemtemplate>                 </asp:templatefield>             </columns>         </asp:gridview>              </div> </asp:content> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -