Accessing Controls Inside GridView Using Javascript function

2010-05-23

I want to access some control lying inside the gridview control, and want to set some value to that control all through javascript.

My gridview control I have set paging for the control with pageSize=10.

The control I need to get in the gridview is in the last column of the gridview.

function SetLowestRate(gridView, pageIndex, DecimalArraylowestRates)

{

var rowCount = gridView.rows.length;

//since 10 is the page size & 0th row is header row so 10+1=11 if gridview has 10 records so set rowCount = 11

if (rowCount > 10)

rowCount = 11;

else if(pageIndex >= 1)

rowCount = rowCount - 1; //Minus the footer row

var arrayIndex = 10 * pageIndex;//Page size =10



for (var rowIndex = 1; rowIndex < rowCount; rowIndex++)

{

var rowElement = gridView.rows[rowIndex];

var lastCellIndex = rowElement.cells.length;





//Access the QuadraQuantityTextBox in this row which is always the last cell

var QuadraQuantityTextBox = rowElement.cells[lastCellIndex - 1].childNodes[0];

QuadraQuantityTextBox.value = Number(DecimalArraylowestRates[arrayIndex]).value;

arrayIndex++;

}

}



Works in following






0 comments: