如何将转发器项的值传递给Jquery? [英] How Do I Pass The Value Of A Repeater Item To A Jquery?

查看:57
本文介绍了如何将转发器项的值传递给Jquery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试在嵌套转发器中使用日期选择器。但每当我尝试通过单击文本框更改转发器的第2或第3项中的日期时,将按预期显示日历。但是我选择的值显示在转发器的第1项中。





这是javascript:



Hi,

i am trying to use a datepicker within a nested repeater. but everytime i try to change the date in the 2nd or 3rd item of the repeater by clicking the textbox, a calendar appears as expected. But the value I select is displayed in the 1st item of the repeater.


Here is the javascript:

<script type="text/javascript">
       var e = jQuery.noConflict();
       e(document).ready(function () {
           e("#<%= datepicker.ClientID %>, #datepicker").datepicker({
               changeMonth: true,
               changeYear: true
           });
       });
</script>





这是我的aspx代码:





Here is my aspx code:

<asp:Repeater runat="server" ID="rpfollowup">
                <ItemTemplate>
               
<div class="widget-body">
			
						
                                  <!-- Group -->
                              <div class="control-group">

<table border="0" width="100%">
  <tr>
    
    <td align="right"><label class="control-label" style="width:auto; float:none;">  مخرج:</label></td>
      <td align="right" width="75%"><asp:TextBox runat="server" ID="txtOut" Text='<%#Eval("Output")%>'></asp:TextBox></td>
  
    
    </tr>
    
           <tr>
     <td align="right"><asp:TextBox runat="server" ID="ffid" Visible="false" Text='<%#Eval("id")%>'></asp:TextBox></td></tr>

 
</table>
                  <div class="row-fluid">              
                                     <asp:Repeater runat="server" ID="rpactivity" >
                <ItemTemplate>
                                  <table width="100%" border="0" cellpadding="0" cellspacing="0">

        <thead>
	<tr>
                            <th style="font-weight:bold" width="150" height="40" >الأنشطة </th>

                        <th style="font-weight:bold" width="150" height="40" >تاريخ البدء</th>
	</tr>
</thead>
        <tr>
            
              <td > <asp:TextBox  ID="Activities" runat="server" CssClass="span10"   Text='<%#Eval("Activity")%>'></asp:TextBox></td>
            <td > <asp:TextBox  ID="datepicker" runat="server" CssClass="span10" ClientIDMode="Static"  Text='<%#Eval("Start_Date")%>'></asp:TextBox></td>
 
        </tr>  
   
    </table>  </ItemTemplate></asp:Repeater>
   

						  </div></div>  
								
                                
				
				</div>

                
                 </ItemTemplate>
                </asp:Repeater>





如何在嵌套转发器中传递文本框(datepicker)的值到jquery,我如何改变我的jquery?在此先感谢



how can i pass the value of the textbox(datepicker) within the nested repeater to the jquery and how do i have to change my jquery? Thanks in advance

推荐答案

问题是您有多个相同的ID - 使用类而不是根据行号或其他一些条件更改ID,以便每行有唯一的calendarID。您可以在OnDataBound事件中执行此服务器端。



将类.datepicker-repeater添加到项目模板。



The problem is that you're having multiple identical IDs - use class instead and change ID based on row number or some other criteria so that each row has unique calendarID. You can do this server side in OnDataBound event.

Add the class .datepicker-repeater to item template.

e(document).ready(function () {
        e(".datepicker-repeater").datepicker({
            changeMonth: true,
            changeYear: true
        });









如果这有助于请花时间接受解决方案。谢谢。





If this helps please take time to accept the solution. Thank you.


这篇关于如何将转发器项的值传递给Jquery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆