We have a table, which uses data binding to generate the contents of the table. Initially there will be one blak row in the table, which is acheived by binding to a blank xml string(xml schema is same but no values). Later on when the user does something we get the actual xml string and uses it to repopulate the table contents. We have to perform some operations based on the data populated in tables i.e. some controls get generated and we need to access them. We are getiing object required error when we try to perform any operation on a control, which is changed because of the data binding. Things work if we put an alert just before performing any operation on the affected control
Here is the code which we are trying to use and getting an error. In this initially there is one row for control "Name" after databinding it should have 3 rows. So if we try to access the 2nd element we get an error. I have commented the alert and things doesn't work whereas it works if I uncomment the alert.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test ASP</title>
</head>
<body>
<script language="JavaScript">
var strXML = "<Results>" +
" <Record>" +
" <Name>Steve</Name>" +
" </Record>" +
" <Record>" +
" <Name>Mike</Name>" +
" </Record>" +
" <Record>" +
" <Name>John</Name>" +
" </Record>" +
"</Results>"
function Test()
{
divDataIsland.innerHTML = '<XML id=xmlList>' + strXML + '</XML>';
tblList.datasrc = '';
tblList.datasrc = '#xmlList';
divDataIsland.style.display = 'block';
//alert("here"
document.frmTest.txtName(0).value="Ramesh"
}
//-->
</script>
<form name="frmTest" method="post">
<div id="divDataIsland" class="DataIsland">
<xml id="xmlList">
</xml>
</div>
<br>
<table id="tblMain" border="0" width="20%" cellpadding="0">
<tr>
<td width="25%" valign="top"><br>
<table border="1">
<tr>
<th width="20%">Name</th>
</tr>
</table>
<div id="divLocal" scrolling="yes" style="WIDTH:990px; HEIGHT:304px; DISPLAY: block;">
<table id="tblList" name="tblList" datasrc="#xmlList" width="25%" border="1">
<tr>
<td width="20%">
<input type="text" id="txtName" name="txtName" datafld="Name" size="13" value="">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br>
<table style="WIDTH:760px; HEIGHT:53px">
<tr>
<td colspan="2">
<input id="btnBind" name="btnBind" type="button" value="Bind XML"
onclick="Test();">
</td>
</tr>
</table>
</form>
</body>
</html>
Here is the code which we are trying to use and getting an error. In this initially there is one row for control "Name" after databinding it should have 3 rows. So if we try to access the 2nd element we get an error. I have commented the alert and things doesn't work whereas it works if I uncomment the alert.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test ASP</title>
</head>
<body>
<script language="JavaScript">
var strXML = "<Results>" +
" <Record>" +
" <Name>Steve</Name>" +
" </Record>" +
" <Record>" +
" <Name>Mike</Name>" +
" </Record>" +
" <Record>" +
" <Name>John</Name>" +
" </Record>" +
"</Results>"
function Test()
{
divDataIsland.innerHTML = '<XML id=xmlList>' + strXML + '</XML>';
tblList.datasrc = '';
tblList.datasrc = '#xmlList';
divDataIsland.style.display = 'block';
//alert("here"
document.frmTest.txtName(0).value="Ramesh"
}
//-->
</script>
<form name="frmTest" method="post">
<div id="divDataIsland" class="DataIsland">
<xml id="xmlList">
</xml>
</div>
<br>
<table id="tblMain" border="0" width="20%" cellpadding="0">
<tr>
<td width="25%" valign="top"><br>
<table border="1">
<tr>
<th width="20%">Name</th>
</tr>
</table>
<div id="divLocal" scrolling="yes" style="WIDTH:990px; HEIGHT:304px; DISPLAY: block;">
<table id="tblList" name="tblList" datasrc="#xmlList" width="25%" border="1">
<tr>
<td width="20%">
<input type="text" id="txtName" name="txtName" datafld="Name" size="13" value="">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br>
<table style="WIDTH:760px; HEIGHT:53px">
<tr>
<td colspan="2">
<input id="btnBind" name="btnBind" type="button" value="Bind XML"
onclick="Test();">
</td>
</tr>
</table>
</form>
</body>
</html>