通过js给gridview内的textbox赋值
1 <script type="text/javascript"> 2 function Check() 3 { 4 var tb=document.getElementById("<% = GridView1.ClientID %>"); 5 for (i=1;i<tb.rows.length;i++) 6 { 7 var cb = tb.rows[i].getElementsByTagName("input")[1]; 8 var textbox = tb.rows[i].getElementsByTagName("input")[0]; 9 if(cb.checked) 10 { 11 textbox.value="aaa"; 12 textbox.readOnly = false; 13 textbox.style.backgroundColor="white"; 14 } 15 else 16 { 17 textbox.readOnly = true; 18 textbox.style.backgroundColor="Gainsboro"; 19 } 20 } 21 } 22 </script>

点击checkbox后textbox内容改变
本文介绍了一种使用JavaScript操作ASP.NET GridView中TextBox的方法,通过遍历表格行并根据复选框的状态来设置TextBox的值、只读属性及背景颜色。
1万+

被折叠的 条评论
为什么被折叠?



