DataGrid/GridView双击行弹出窗口
DataGrid:
private void dgUser_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ccddee'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
if( e.Item.Cells[6].Text.ToLower() == "false" )
e.Item.Cells[6].Text = "<font color=\"green\">使用中</font>" ;
else
e.Item.Cells[6].Text = "<font color=\"red\">停用</font>" ;
}
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.SelectedItem) )
{
e.Item.Attributes.Add ("ondblclick", "javascript:window.open('./UserEdit.aspx?UserID="+ e.Item.Cells[0].Text.Replace(" ","").Trim() +" ','window','toolbar=no ,scrollbars=yes ,resizable=no,top=200,left=200,Width=600,Height=200');");
}
}
GridView:
protected void gvCustom_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ccddee'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
//设置悬浮鼠标指针形状为"小手"
e.Row.Attributes["style"] = "Cursor:hand";
ImageButton imgFlag = new ImageButton();
imgFlag = ((ImageButton)e.Row.Cells[7].Controls[0]);
if (imgFlag.AlternateText == "删除")
{
imgFlag.Attributes.Add("onclick", "javascript:return confirm('您确信要删除:\"" +e.Row.Cells[1].Text+"\" 吗?')");
//Button btn = (Button)e.Row.Cells[5].Controls[0];
//btn.Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
//Button1.Attributes.Add("onclick","return confirm(’确认?’)");
//button.attributes.add("onclick","if(confirm(’are you sure
?’)){return true;}else{return false;}") }
//设置弹出窗体
//string CustomID= gvCustom.DataKeys[ e.Row.RowIndex]["CustomID"].ToString() ;
//e.Row.Attributes.Add("ondblclick", "javascript:window.showModalDialog('./CustomInfo.aspx?CustomID=" + CustomID + "',window,'scroll:no;status:no;center:yes;dialogHeight:480px;dialogWidth:700px;');");
}
}

浙公网安备 33010602011771号