By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,127 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,127 IT Pros & Developers. It's quick & easy.

Collectiong Data on Server side while adding rows on client side

P: n/a
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
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.