title: ASP.NET : Get Label inside Repeater using JQuery based on custom attribute
body: <p>i read so many solutions and blogs on this but still not able to get it done.</p>
  
  <p>I have a Repeater in my code, which has labels in ItemTemplate. I need to do a client side validation (using jQuery) on the values entered in the TextBox on a button click event. i have some value in my label which I want to access to make comparision between the values entered in the textbox and text of label. Now I added a custom attribute named datakey to the label and textbox both, so that comparision is easy. </p>
  
  <p>I access the text box and get the datakey attribute.
  I get the label with the datakey value same as that of textbox and do my comparision.</p>
  
  <p>Now in Jquery I am not able to access that label.</p>
  
  <p>This is what i wrote in Jquery:</p>
  
  <pre><code>var lbl = $("label").find("[datakey='" + expID + "']");
  </code></pre>
  
  <p>ASP Code.</p>
  
  <pre><code>&lt;table class="tblDispData"&gt;
      &lt;asp:Repeater ID="PrjBudgetDetails" runat="server" ClientIDMode="Static"&gt;
          &lt;HeaderTemplate&gt;
              &lt;tr&gt;
                  &lt;th class="thDataDisp"&gt;
                      &lt;asp:Label ID="LbExpType" runat="server" Text="Expenditure Type" CssClass="LbTblDataDisp"
                          Font-Bold="true"&gt;&lt;/asp:Label&gt;
                  &lt;/th&gt;
                  &lt;th class="thDataDisp"&gt;
                      &lt;asp:Label ID="LbAllocatedBudget" runat="server" Text="Allocated Budget" CssClass="LbTblDataDisp"
                          Font-Bold="true"&gt;&lt;/asp:Label&gt;
                  &lt;/th&gt;
                  &lt;th class="thDataDisp"&gt;
                      &lt;asp:Label ID="LbAvailedBudget" runat="server" Text="Available Budget" CssClass="LbTblDataDisp"
                          Font-Bold="true"&gt;&lt;/asp:Label&gt;
                  &lt;/th&gt;
                  &lt;th class="thDataDisp"&gt;
                      &lt;asp:Label ID="LbRequestedBudget" runat="server" Text="Budget Requested" CssClass="LbTblDataDisp"
                          Font-Bold="true"&gt;&lt;/asp:Label&gt;
                  &lt;/th&gt;
              &lt;/tr&gt;
          &lt;/HeaderTemplate&gt;
          &lt;ItemTemplate&gt;
              &lt;tr&gt;
                  &lt;td class="tdDataDisp"&gt;
                      &lt;asp:Label ID="ExpTypeText" runat="server" Text='&lt;%#Eval("ExpType") %&gt;' CssClass="LbTblDataDisp"
                          AssociatedControlID="BudgetRequestedText"&gt;&lt;/asp:Label&gt;
                  &lt;/td&gt;
                  &lt;td class="tdDataDisp"&gt;
                      &lt;asp:Label ID="BudgetAllocatedText" runat="server" Text='&lt;%#Eval("BudgetAllocated") %&gt;'
                          CssClass="LbTblDataDisp" AssociatedControlID="BudgetRequestedText"&gt;&lt;/asp:Label&gt;
                  &lt;/td&gt;
                  &lt;td class="tdDataDisp"&gt;
                      &lt;asp:Label ID="BudgetAvailableText" runat="server" dataKey='&lt;%#Eval("ExpID") %&gt;'
                          Text='&lt;%#Convert.ToDouble(Eval("BudgetAllocated")) - Convert.ToDouble(Eval("BudgetAvailed")) %&gt;'
                          CssClass="LbTblDataDisp" ClientIDMode="Static" AssociatedControlID="BudgetRequestedText"&gt;&lt;/asp:Label&gt;
                  &lt;/td&gt;
                  &lt;td class="tdDataDisp"&gt;
                      &lt;asp:TextBox ID="BudgetRequestedText" runat="server" dataKey='&lt;%#Eval("ExpID") %&gt;'
                          dataValue='&lt;%#Eval("ExpType") %&gt;' CssClass="tblDataInput"&gt;&lt;/asp:TextBox&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:Repeater&gt;
      &lt;tr&gt;
          &lt;td colspan="3"&gt;
              &lt;span id="Legend1" class="frmInstructions" runat="server"&gt;Please enter zero(0) if not
                  requesting budget for any particular expenditure. The currency is INR. &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;asp:Button ID="prjBudgetSubmitBtn" runat="server" Text="Submit Budget" CssClass="formNext"
                  ClientIDMode="Static" OnClick="prjBudgetSubmitBtn_Click" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>The RESULTING MARKUP HERE</p>
  
  <pre><code>&lt;table class="tblDispData"&gt;
  
                                  &lt;tr&gt;
                                      &lt;th class="thDataDisp"&gt;
                                          &lt;span id="LbExpType" class="LbTblDataDisp" style="font-weight:bold;"&gt;Expenditure Type&lt;/span&gt;
                                      &lt;/th&gt;
                                      &lt;th class="thDataDisp"&gt;
                                          &lt;span id="LbAllocatedBudget" class="LbTblDataDisp" style="font-weight:bold;"&gt;Allocated Budget&lt;/span&gt;
                                      &lt;/th&gt;
                                      &lt;th class="thDataDisp"&gt;
                                          &lt;span id="LbAvailedBudget" class="LbTblDataDisp" style="font-weight:bold;"&gt;Available Budget&lt;/span&gt;
                                      &lt;/th&gt;
                                      &lt;th class="thDataDisp"&gt;
                                          &lt;span id="LbRequestedBudget" class="LbTblDataDisp" style="font-weight:bold;"&gt;Budget Requested&lt;/span&gt;
                                      &lt;/th&gt;
                                  &lt;/tr&gt;
  
                                  &lt;tr&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="ExpTypeText" class="LbTblDataDisp"&gt;Hardware&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAllocatedText" class="LbTblDataDisp"&gt;9.00&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAvailableText" class="LbTblDataDisp" dataKey="EXP001"&gt;7&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;input name="ctl00$pageMainContent$PrjBudgetDetails$ctl01$BudgetRequestedText" type="text" id="BudgetRequestedText" class="tblDataInput" dataKey="EXP001" dataValue="Hardware" dataAmount="7" /&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
  
                                  &lt;tr&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="ExpTypeText" class="LbTblDataDisp"&gt;Software&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAllocatedText" class="LbTblDataDisp"&gt;9.00&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAvailableText" class="LbTblDataDisp" dataKey="EXP002"&gt;9&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;input name="ctl00$pageMainContent$PrjBudgetDetails$ctl02$BudgetRequestedText" type="text" id="BudgetRequestedText" class="tblDataInput" dataKey="EXP002" dataValue="Software" dataAmount="9" /&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
  
                                  &lt;tr&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="ExpTypeText" class="LbTblDataDisp"&gt;Software AMC&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAllocatedText" class="LbTblDataDisp"&gt;9.00&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAvailableText" class="LbTblDataDisp" dataKey="EXP003"&gt;9&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;input name="ctl00$pageMainContent$PrjBudgetDetails$ctl03$BudgetRequestedText" type="text" id="BudgetRequestedText" class="tblDataInput" dataKey="EXP003" dataValue="Software AMC" dataAmount="9" /&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
  
                                  &lt;tr&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="ExpTypeText" class="LbTblDataDisp"&gt;Hardware AMC&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAllocatedText" class="LbTblDataDisp"&gt;9.00&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAvailableText" class="LbTblDataDisp" dataKey="EXP004"&gt;9&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;input name="ctl00$pageMainContent$PrjBudgetDetails$ctl04$BudgetRequestedText" type="text" id="BudgetRequestedText" class="tblDataInput" dataKey="EXP004" dataValue="Hardware AMC" dataAmount="9" /&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
  
                                  &lt;tr&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="ExpTypeText" class="LbTblDataDisp"&gt;UPS&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAllocatedText" class="LbTblDataDisp"&gt;9.00&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;label for="BudgetRequestedText" id="BudgetAvailableText" class="LbTblDataDisp" dataKey="EXP006"&gt;9&lt;/label&gt;
                                      &lt;/td&gt;
                                      &lt;td class="tdDataDisp"&gt;
                                          &lt;input name="ctl00$pageMainContent$PrjBudgetDetails$ctl05$BudgetRequestedText" type="text" id="BudgetRequestedText" class="tblDataInput" dataKey="EXP006" dataValue="UPS" dataAmount="9" /&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
  
                          &lt;tr&gt;
                              &lt;td colspan="3"&gt;
                                  &lt;span id="pageMainContent_Legend1" class="frmInstructions"&gt;Please enter zero(0) if not
                                      requesting budget for any particular expenditure. The currency is INR. &lt;/span&gt;
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;input type="submit" name="ctl00$pageMainContent$prjBudgetSubmitBtn" value="Submit Budget" id="prjBudgetSubmitBtn" class="formNext" /&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>