我无法复制或自动绑定到第二个文本框。我需要处理哪个事件,onkeyup
或onblur
?
这是我的代码:
<script type="text/javascript">
function OneTextToother()
{
var first=document.getElementById(txtQuantity).value;
document.getElementById(txtQuantity1).value=first;
}
</script>
<asp:GridView ID="gvOrder" runat="server" OnRowDataBound="gvOrder_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" onkeyup="javascript:OneTextToother();" >
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtQuantity1" runat="server" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
答案 0 :(得分:1)
您可以使用Client Id property
<%# ((GridViewRow)Container).FindControl("txtQuantity1").ClientID %>
所以
var first = document.getElementById('<%# ((GridViewRow)Container).FindControl("txtQuantity").ClientID %>');
document.getElementById('<%# ((GridViewRow)Container).FindControl("txtQuantity1").ClientID %>').value=first;