我想实现一个在父窗体中点击一个用户名,弹出一个小窗口里面显示从数据库跟据传值提取的相关数据,这要怎么实现啊,最好能给代码

解决方案 »

  1.   

    http://download.csdn.net/source/588057
      

  2.   

    主页面
    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.lbUser.Text = User.Identity.Name;
                this.lbUser.OnClientClick = "window.open('showdata.aspx?userid=" & User.Identity.Name & "','')";
            }
        }
    </script><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:LinkButton ID="lbUser" runat="server"></asp:LinkButton>
            </div>
        </form>
    </body>
    </html>
    弹出页面
    <%@ Page Language="C#" %><%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.Sql" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">    protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("connectionString");
            SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM table_name WHERE userid='" & Request.QueryString["userid"] & "'", conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            this.dgShowData.DataSource = dt;
            this.dgShowData.DataBind();
        }
    </script><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:DataGrid ID="dgShowData" runat="server">
                </asp:DataGrid>
            </div>
        </form>
    </body>
    </html>
      

  3.   


    楼上是说我吗,我的showdata.aspx就是用一个datagrid来显示数据的啊~
      

  4.   

    <input type="button" value="test" onclick="window.showModalDialog('test.aspx?userid=1')" />
      

  5.   


    我已经用了工厂模式,数据由DAL类提供
      

  6.   

    用window.showModalDialog('test.aspx?userid=1')
    后面还可以带些参数,来控制弹出窗口的大小
      

  7.   

    3楼的非常正确啊。
    AJAX有个控件也可以实现
      

  8.   

    都说了用这个啦window.showModalDialog('test.aspx?userid=1')
      

  9.   

    3楼的是弹出一个页面窗口啊 window.open()和window.showModalDialog()都可以
    window.showModalDialog()是个模式的窗口 总是在最上的
      

  10.   

    3楼的是弹出一个页面窗口啊 window.open()和window.showModalDialog()都可以
    window.showModalDialog()是个模式的窗口 总是在最上的
      

  11.   

    window.showModalDialog('test.aspx',window,'dialogWidth:300px;dialogHeight:200px;help:no;' )