日期:2014-05-16  浏览次数:20585 次

求助,如何解决这个问题!
      在学校刚开始学着做东西,要做b/s的一个查询,想实现在GridView中点击任意一行可以弹出一个div,在div中显示选中行的用户详细信息,比如GridView1显示用户名等基本信息和他的记录总数,点击后传GridView1的绑定值DataKeys,用DataKeys作详细信息的查询,显示该用户细致的记录信息:
 //form.aspx.cs
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "c=style.backgroundColor;style.backgroundColor='#00A9FF'");
                e.Row.Attributes.Add("onmouseout", "style.backgroundColor=c");
                e.Row.Attributes.Add("onclick", "javascript:open('" + value + "');");");
            }
        }

都说这样的功能必须用ajax异步传值才可以,我就照猫画虎的试了下...
//form.aspx
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
function open(value) {
            if (View1.style.visibility == 'visible') {
                View1.style.visibility = 'hidden'
            }
            else {
                View1.style.visibility = 'visible';
                View1.style.top = event.clientY;
                View1.style.left = event.clientX;
                $.ajax({
                    type: "post",
                    url: "form1.aspx",
                    data: "id=" + value,
                    dataType: "text",
                    success: function (msg) {
                        $("div#View1").html(msg);
                    }
                });
            }
        }
</script>