Collectiong Data on Server side while adding rows on client side

G

Guest

Hi

I have html table and a Button in an Aspx page. I am adding one row with
some textboxes to Html table each time i click on the Button thru Javascript.

Now problem is when when i try to collect the data in the Textboxes which i
added dynamically from server side, i am not able to do . Alos i tried to
bedug, the total no of rows in Html table does not reflect the dynamically
added rows.

What i mean is, For Ex, If have one row in html tble, and i clciked the
Button twice. It adds 2 rows. Now the total no of rows are 3. But when i
dbug, it stiill shows Table.rows.count is 1.

Any help is appreciated.

Here is my code
Javascript to add rows dynamically
//Adding New Row IncMat
//
function addNewRowInCorrespondingTab1(){

try
{
addRowInIncMaterial();
}
catch(e)
{
alert("Problem in adding new row...");
window.status = "Problem in adding new row...";
return false;
}
return false;
}
//
function addRowInIncMaterial(){

var theTable;
var lastRow;
var row;
var cell;
var el;
var NoOfCol;
//
theTable = document.getElementById('IncomingMateTbl');
lastRow = theTable.rows.length - 1;
row = theTable.insertRow(2);
//
var DDLText = 'Select,Stage,Eng';
//
NoOfCol = parseInt(4);
for(i = 1; i <= (NoOfCol); i++)
{
if (i == 1)
{
aryDDLText = DDLText.split(",");
cell = row.insertCell(i - 1);
cell.setAttribute('align','center');
el = document.createElement('select');
el.setAttribute('Font-Size', '9pt');

el.setAttribute('name', 'IncMat' + (lastRow) + i);
el.setAttribute('id', 'IncMat' + (lastRow) + i);
//
for(id = 0; id < aryDDLText.length; id++)
{
if (id==0)
{
oNewOption = new Option();
oNewOption.text = aryDDLText[id];
oNewOption.value = '0';
}
else
{
oNewOption = new Option();
oNewOption.text = aryDDLText[id];
oNewOption.value = aryDDLText[id];
}
el.add(oNewOption,id);
cell.appendChild(el);
}
}
else
{
cell = row.insertCell(i - 1);
cell.setAttribute('align','center');
el = document.createElement('input');
el.setAttribute('type', 'text');
//
el.setAttribute('name', 'IncMat' + (lastRow) + i);
el.setAttribute('id', 'IncMat' + (lastRow) + i);
//
el.setAttribute('value', '');
el.setAttribute('size', '11');
el.setAttribute('Fontsize', '9pt');
cell.appendChild(el);
}
}
//
}
//

Server Side Code

Dim IncMatIdx As Integer
Dim ctr As Integer
Dim Ptr As New HtmlTableRow()
Dim inputTxt As New HtmlInputText()
Dim InputDDL As New DropDownList()

IncMatIdx = IncomingMateTbl.Rows.Count
For ctr = 1 To ctr <= IncMatIdx
Ptr = IncomingMateTbl.Rows(ctr)
'
InputDDL = CType(Ptr.Controls.Item(0).Controls.Item(0),
DropDownList)
DetailDataObj2.SetIncomingMat("IncMaterial",
InputDDL.SelectedItem.Value)
'
inputTxt = CType(Ptr.Controls.Item(1).Controls.Item(0),
HtmlInputText)
DetailDataObj2.SetIncomingMat("Batch", inputTxt.Value)

inputTxt = CType(Ptr.Controls.Item(2).Controls.Item(0),
HtmlInputText)
DetailDataObj2.SetIncomingMat("PCN", inputTxt.Value)

inputTxt = CType(Ptr.Controls.Item(3).Controls.Item(0),
HtmlInputText)
DetailDataObj2.SetIncomingMat("Qty", inputTxt.Value)
'
InfoObj.AddSMODetail(DetailDataObj2)
Next




Thx in advance
Sileesha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top