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];
}