日期:2014-05-17  浏览次数:20990 次

动态往table中添加行,行的对应列中含有DropDownList 服务器控件,怎么绑定数据到该控件
ASP.NET+c#
代码如下:  
实现动态添加行的JS代码如下
        function addRow(tabObj, colNum, targPos) {
            var sorPos = parseInt("<%=GetLinCount()%>") + 4;
            var IDTab = String(sorPos);
            var nTR = tabObj.insertRow(tabObj.rows.length - targPos); 
            var TRs = tabObj.getElementsByTagName('tr'); // Get TRs collection from the appointed table 
            var sorTR = TRs[sorPos];                     // Positioned the sorTR 
            var TDs = sorTR.getElementsByTagName('td');     
            if (colNum == 0 || colNum == undefined || colNum == isNaN) {
                colNum = tabObj.rows[4].cells.length;
            }
            var ntd = new Array();                       // Create a new TDs array 
            for (var i = 0; i < colNum; i++) {
                ntd[i] = nTR.insertCell();
                if (0 == i) {
                    ntd[i].style.cssText = "BORDER-TOP:  #168bd9   2px   solid;BACKGROUND-COLOR: #168bd9";
                }
                else {
                    if (1 == i) {
                        ntd[i].id = "name" + IDTab;
                        
                    }
                    if (2 == i) {
                       &n