问题:一个下拉框
     我在 index.aspx 的 <form id="Form1" method="post" runat="server" action="index.aspx">  提交
      <input id="hh" type="hidden" name="hh" runat="server">
     function bao(s) 
    {
      document.getElementById("<%=hh.ClientID%>").value=s;
    }在后台CS的index.aspx.cs : 
                protected System.Web.UI.HtmlControls.HtmlInputHidden hh;
                private void Page_Load(object sender, System.EventArgs e)
{
                  Response.Write("--->"+this.hh.Value);//这边有输出值 。。
                }
 private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
                     Response.Write("--->"+this.hh.Value);//但是为什么这边输不出值来呢 。。    
                }
                private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load);
this.SG1.DataGrid1.ItemDataBound += new DataGridItemEventHandler(DataGrid1_ItemDataBound);
}

解决方案 »

  1.   

    为什么不执行到这
      private   void   DataGrid1_ItemDataBound(object   sender,   DataGridItemEventArgs   e) 

                                              Response.Write("---> "+this.hh.Value);//但是为什么这边输不出值来呢   。。         
                                    } 
      

  2.   

    页面第一次加载的时候有执行到这个,但是当表单<form   id="Form1"   method="post"   runat="server"   action="index.aspx"> 
        action="index.aspx" 这个的时候就不执行下面那个DataGrid方法了
         private       void       DataGrid1_ItemDataBound(object       sender,       DataGridItemEventArgs       e)   
    {   
                                                                                        Response.Write("--->   "+this.hh.Value);//但是为什么这边输不出值来呢       。。                   
                                                                    }   
      

  3.   

    单独写个函数 别写在DataGrid1_ItemDataBound里面