GridView双击回传父页面及改变选择行颜色

这篇博客探讨了如何在GridView组件中实现双击操作,将选中行的数据回传到父页面。通过使用window.showModalDialog方法,可以将父页面的对象传递给子页面,实现实时交互。子页面的实现则相对简单。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

父页面(略)

其中window.showModalDialog中第二个参数可以将父页面对象传给子页面

子页面

   protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    
{
        
if (e.Row.RowType == DataControlRowType.DataRow)
        
{
            e.Row.Attributes.Add(
"onmouseover","color = this.style.backgroundColor;this.style.backgroundColor='#0000ff';this.style.cursor='hand'");
            e.Row.Attributes.Add(
"onmouseout""this.style.backgroundColor=color");
        }

    }


  
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    
{
        
if (e.Row.RowType == DataControlRowType.DataRow)
        
{
            e.Row.Attributes.Add(
"ondblClick ""GetKey('" + e.Row.Cells[0].Text + "')");
        }

    }


function GetKet(text)
{
        
//window.open
        window.opener.document.getElementById("txt11").value = text;
       
//showModelDialog
       var control = window.dialogArguments;
       control.value 
= text;
}

很简单!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值