如何使用Javascript访问DataListDataGrid内部的控件 [英] How to access the controls that are inside of a DataListDataGrid using Javascript
本文介绍了如何使用Javascript访问DataListDataGrid内部的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题很简单,我有一个datalist控件,里面有一些控件
EditTemplate(问题在DataGrid中是一样的)。我希望使用javascript对
访问此控件,但
我不能。我该怎么做?
My problem is simple, i have a datalist control with some controls inside of
EditTemplate (the problem is the same in the DataGrid). I want to have
access to this controls, using javascript, but
i can't. How can i do this?
<Code>
<script language="javascript">
document.getElementById('<%=txt1.ClientID %>').value='test';
document.getElementById('<%=txt2.ClientID %>').value='test';
</script>
....
<asp:DataList id="Test" ...><EditItemTemplate>
<asp:textbox id="txt1" runat=server></asp:textbox></EditItemTemplate>
</asp:DataList>...
<asp:textbox id="txt2" runat=server></asp:textbox>
</Code>
推荐答案
在datagrid中他们不是添加了行。您可以使用JavaScript访问
In datagrid their are no of rows added. You can access using JavaScript
(文档).ready(function(){
//网格名行属性事件
(document).ready(function(){
// Gridname row attribute event
(#EvoEditGrid0 tr)。live(change,function(){
if(!this.rowIndex)return;
//访问一行中的列
for(var i = 0; i< this.cells.length; i ++)>
{
// txt1 id
var item =
("#EvoEditGrid0 tr").live("change",function() {
if (!this.rowIndex) return;
//to access columns in a row
for(var i=0; i<this.cells.length;i++)>
{
//txt1 id
var item=
这篇关于如何使用Javascript访问DataListDataGrid内部的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文