我这里有个例子,给个E-MAIL!

解决方案 »

  1.   

    我在1.aspx中HTML按钮中的onclick事件中调用show函数:
    <script language="javascript">
    function show()
    {
     document.Form1.TextBox1.value=window.showModalDialog("WebForm2.aspx");
    }
    </script>
    然后在2.aspx中按钮事件中加代码:
    Response.Write("<script> window.returnValue='"+this.TextBox1.Text+"'</script>");
             Response.Write("<script>window.close()</script>");
    目的是让2.aspx中TextBox1中的数据传到1.aspx中的TextBox1中
      

  2.   

    我想 BabyTree(小树)的例子一定能行,我也正在解决这方面的问题,但是我只能过html文件解决。
      

  3.   

    main.aspx里面放个按钮imgbutton1,1X1大小,隐藏吧。
    button1_click()里面 是BindGrid(txtName.text)pop.aspx中,确定按钮,中代码如下:
     Response.Write("<script language=javascript>opener.document.all.txtName.value='" & strName & "';opener.document.all.button1.click();window.close()</script>")原理是 pop.aspx页面更改main.aspx里txtName的值,然后重新绑定datagrid。
      

  4.   

    回传值得到了,  但怎末根据回传值,datagrid显示相应的纪录???
      

  5.   

    恩,同意上面的意见!
    推荐用SESSION解决!
      

  6.   

    推荐用SESSION解决!请说的详细一点,session则怎末解决???谢谢
      

  7.   

    把回传值存放到页面的一个隐藏域中,再在页面上放置一个按钮,大小设为最小,使其在页面上看不到.最后模拟这个按钮点击事件.
    将隐藏域中的内容发送到服务端,服务端再进行相应的处理,根据隐藏域中的内容从数据库中取得内容,显示到datagrid.
      

  8.   

    to:jaffler() main.aspx里面放个按钮imgbutton1,1X1大小,隐藏吧。
    button1_click()里面 是BindGrid(txtName.text)不行,报错BindGrid
      

  9.   

    to senzz(森)按照我的办法做,我就是这么做过的
      

  10.   

    to  :chnking(kent)
    将隐藏域中的内容发送到服务端,服务端再进行相应的处理,根据隐藏域中的内容从数据库中取得内容,显示到datagrid 这一步如何完成?
      

  11.   

    大家不会用Session这种方法做吧,没更好的办法了吗??
    我也在考虑这方面的问题!在1.aspx中有个按钮,点击后弹出2.aspx,2.aspx是个日历表,用户选择一个日期后关闭2.aspx并且修改1.aspx中的一个label的值!!!难道要用上面这么复杂的方法吗???
      

  12.   

    to  :chnking(kent)
    将隐藏域中的内容发送到服务端,服务端再进行相应的处理,根据隐藏域中的内容从数据库中取得内容,显示到datagrid 这一步如何完成?
      

  13.   

    模拟点击了那个看不见的按钮(是服务端控件),就提交到服务器了.
    在服务端这个按钮的点击事件中做如下事:
    1,读取隐藏域的内容
    2,根据隐藏域的内容到数据库取数据放入dataset
    3,把dataset冻datagrid绑定
      

  14.   

    主页面:private void Page_Load(object sender, System.EventArgs e)
    { if (!Page.IsPostBack)
    {
    if(this.TextBox1.Text.Trim() =="")
    {
    pIssue.FillData(this.issueDataSet1,"IssueID");
    }
    else
    {
    pIssue.FillData(this.issueDataSet1,this.TextBox1.Text.Trim());
    }

    this.DataGrid1.DataBind();
    this.DataGrid1.SelectedIndex=0;
    Session.Contents.Add("selectedIssueId","");

    }
    }弹出页面:private void cmdSearch_Click(object sender, System.EventArgs e)
    {
    string Project = this.ProjectSel.SelectedItem.Value.Trim();
    string Status = this.StatusSel.SelectedItem.Value.Trim();
    string AsssginTo = this.AsssginToSel.SelectedItem.Value.Trim();
    string Priority = this.PrioritySel.SelectedItem.Value.Trim();
    string conditionSel = Project + "&" + Status + "&" + AsssginTo + "&" + Priority ;
    Response.Write("<script> window.opener.document.Form1.TextBox1.value = '"+conditionSel+"';opener.refresh();</script>");
    Response.Write("<script language=javascript>window.close();</script>"); }
      

  15.   

    IssueID 是数据库表中的一个字段有些乱,我也有点晕
      

  16.   

    试试这个:
    1、在pop.aspx页面中写一个刷新main.aspx页面的语句:
    Response.Write("window.opener."+main页面的formID+".submit()"+"\n");
    2、在main.aspx文件中放一个隐藏的TextBox,在传值时,传一个值到这个TextBox
    3、在TextBox中的TextChanged事件里加入重新邦定DATAGRID的代码
      

  17.   

    3、在TextBox中的TextChanged事件里加入重新邦定DATAGRID的代码
     先前我已经绑定了,要从新绑定,该怎末做?
    刚接触C#,多多指点!!!
      

  18.   

    然后根据回传值,datagrid显示相应的纪录
    ------------------------------------
    你这次邦定是根据你传回的值来邦定的.两次邦定的SQL语句不同,其它相同.
      

  19.   

    TextChanged事件里根据TextBox值(搜索数据库的条件)去重新获取你要显示的数据,再次同datagrid绑定
      

  20.   

    #region Component Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
    this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    // 
    // sqlDataAdapter1
    // 
    this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
    this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
      new System.Data.Common.DataTableMapping("Table", "Action", new System.Data.Common.DataColumnMapping[] {
    new System.Data.Common.DataColumnMapping("IssueId", "IssueId"),
    new System.Data.Common.DataColumnMapping("Title", "Title"),
    new System.Data.Common.DataColumnMapping("ItemType", "ItemType"),
    new System.Data.Common.DataColumnMapping("Area", "Area"),
    new System.Data.Common.DataColumnMapping("MileStone", "MileStone"),
    new System.Data.Common.DataColumnMapping("Project", "Project"),
    new System.Data.Common.DataColumnMapping("Priority", "Priority"),
    new System.Data.Common.DataColumnMapping("Status", "Status"),
    new System.Data.Common.DataColumnMapping("AssignTo", "AssignTo")})});
    // 
    // sqlSelectCommand1
    // 
    this.sqlSelectCommand1.CommandText = @"SELECT Issue.IssueId, Issue.Title, Issue.ItemType, Issue.Area, Issue.MileStone, Issue.Project, Action.Priority, Action.Status, Action.AssignTo, Action.ActionId, Action.IssueId AS Expr1 FROM Action INNER JOIN Issue ON Action.IssueId = Issue.IssueId WHERE (Action.ActionId IN (SELECT MAX(ActionId) FROM Action GROUP BY IssueId))";
    this.sqlSelectCommand1.Connection = this.sqlConnection1;
    // 
    // sqlConnection1
    // 
    this.sqlConnection1.ConnectionString = "data source=服务器;initial catalog=issuetracker;persist security info=False;" +
    "user id=;password=;workstation id=服务器;packet size=4096";这是原来的sql语句,这次该怎末绑定,我怎末把传回的值作为条件写新的sql??? }
    #endregion
      

  21.   

    to:chnking(kent) 你也帮我看一下代码,TextBox得值怎末作为新的条件传入原来的sql语句
      

  22.   

    TextChanged事件里面,重新建立
    this.sqlDataAdapter1 
    this.sqlSelectCommand1
    并给sqlSelectCommand1赋以根据TextBox的sql语句,再sqlDataAdapter1.Fill基本上要把你上面列的代码都要在TextChanged事件里面再来一次
      

  23.   

    上面说的有误,应该是这样:你上面的代码是用数据向导做的,在InitializeComponent()中已经把sqlDataAdapter1,sqlSelectCommand1,sqlConnection1初始化为你设计时的值了.所以在TextChanged事件里面只要修改sqlSelectCommand1就行了:
    private void TextBox1_TextChanged(object sender, System.EventArgs e)
    {
        sqlSelectCommand1.CommandText = "";  //这里就是根据TextBox内容生成的sql语句了
        sqlDataAdapter1.Fill(ds,"tablename");  //填充dataset,作为datagrid的数据源
    }
      

  24.   

    上面的问题基本解决了,谢谢大家!!还有一点,我添加了分页功能,怎末保证分页和排序(就是根据TextBox的值重新查询数据库,然后在Datagrid中显示出来)功能都可以正常执行??在没有排序功能时,分页正常,但加上排序功能后,当我点击分页的“第二页”时,数据没有显示出来???private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
    {
    pIssue.FillData(this.issueDataSet1,"IssueId");
    DataGrid1.CurrentPageIndex = e.NewPageIndex;
    DataGrid1.DataBind();
    }
      

  25.   

    private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
    {
    if( (this.TextBoxPro.Text == "" )//即排序前的显示数据
    {
    pIssue.FillData(this.issueDataSet1,"IssueId");
    DataGrid1.CurrentPageIndex = e.NewPageIndex;
    DataGrid1.DataBind();
    }
    else       //即排序所要显示的数据
    {
    DataGrid1.CurrentPageIndex = e.NewPageIndex;
    this.ButtonSel_Click();
             }
    }private void ButtonSel_Click(object sender, System.EventArgs e)
    {//这里是Datasouce,DataBind,sqlDataAdapter}
    出现的问题是入上所写,报错!!
    但是如果把else中的this.ButtonSel_Click();去掉,而代之以private void ButtonSel_Click中的全部代码,就没有问题为什末是这样???
    谢谢!!请指点一下!!
      

  26.   

    谁有成功的页面,给我发一个啊
    [email protected]
    我做的第二个form点击按钮的时候会再弹出一个跟第二个form一样的页面,
    就好像按了一下Ctrl+N一样