protected void LinkButton_Clik(object sender, System.EventArgs e)
//DATAGRID模板列中的LINKBUTTON的单击事件
{
SqlCommand comm=new SqlCommand();
comm.Connection=this.sqlConn_Notice;
comm.CommandText="Display_Notice";
comm.CommandType=CommandType.StoredProcedure; comm.Parameters.Add("@NotTitle",SqlDbType.VarChar,100,"NotTile");
comm.Parameters.Add("@NotContent",SqlDbType.VarChar,4000,"NotContent"); comm.Parameters["@NotTitle"].Value=((LinkButton)sender).Text.ToString().Trim();
comm.Parameters["@NotContent"].Direction=ParameterDirection.Output;
this.sqlConn_Notice.Open(); comm.ExecuteNonQuery();
            
ElectSite.NotContent.content=comm.Parameters["@NotContent"].Value.ToString();
     //用静态变量来接收StoreProcedure的输出参数 Response.Redirect("NotContent.aspx",true);//跳到显示详细内容的页面
this.sqlConn_Notice.Close();
}
上面一段是我为DATAGRID的模板列中的一个LINKBUTTON写的事件代码,当点击LINKBUTTON的时候就跳到另一页显示以LINKBUTTON的TEXT为标题的详细内容,content是NotContent类的一个公用静态string变量,用来接收从数据库返回的详细内容。问题就是当我跳到显示详细内容的页面的时候却什么都没有,这是为什么呢?

解决方案 »

  1.   

    你是把把content内容在下个页面里调用吗?
    用ViewState["content"] = comm.Parameters["@NotContent"].Value.ToString();
    第二个页面取ViewState["content"]值
      

  2.   

    还是没有显示,我想会不会是我的这个事件有问题啊?
    我的LINKBUTTON是在DATAGRID的模板列中的,当点击LINKBUTTON的时候就跳到另一页进行显示。
    我在.aspx文件中有这么一段:
    <asp:LinkButton id="LinkButton2" OnClick="LinkButton_Clik" runat="server">
        <%#DataBinder.Eval(Container.DataItem,"NotTitle")%>
    </asp:LinkButton>
    OnClick="LinkButton_Click"就是我要击发的LinkButton事件
    在.aspx.cs文件中相应的处理函数就是:
    protected void LinkButton_Clik(object sender, System.EventArgs e)
    这个是不是对的啊?我总感觉是这个事件没有被击发...
      

  3.   

    我想现在问题可能在这一句上:
    comm.Parameters["@NotTitle"].Value=((LinkButton)sender).Text.ToString().Trim();
    怎么才能把DATAGRID模板列中的LINKBUTTON控件的.Text属性取出来啊?
    我想把它传给存储过程的参数,应该怎么做啊?
      

  4.   

    如何才能在DATAGRID的ItemCommand事件中得到模板列中控件的属性?