RowDataBound事件里:
for(int i=0;i<e.Row.Cells.Count-1;i++)
{
System.Web.UI.Control control = e.Row.Cells[i].Controls[1];
if (control is TextBox)
{
((TextBox)control).Attributes.Add("onclick", "ShowOperateDialog2(this)");
}
}
javascript:
function ShowOperateDialog2(sender)
{
var row=sender.parentElement.parentElement;
// alert(row.cells.length);
var str = showModalDialog('../Selectors/Selector_Medicines.aspx','window','dialogWidth:720px;dialogTop:'+150+'px;dialogHeight:570px;center:yes;help:no;resizable:no;status:no');
var returnValue=str.split('|');
var RowCellCount = row.cells.length - 2;
for(i=0;i<RowCellCount;i++)
{
value = returnValue[i];
if(value==" ")
{
value="";
}
row.cells[i].getElementsByTagName("INPUT")[0].value=value;
}
document.getElementById("HiddenField1").value=returnValue[9];
document.getElementById("HiddenField2").value=returnValue[10];
}
本文介绍了如何在RowDataBound事件中遍历表格的每一项,并为特定类型的控件添加JavaScript事件处理程序。此外,还详细解释了如何通过JavaScript与ASP.NET进行交互,包括调用弹出窗口并更新表格单元格中的输入字段。
7085

被折叠的 条评论
为什么被折叠?



