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变量,用来接收从数据库返回的详细内容。问题就是当我跳到显示详细内容的页面的时候却什么都没有,这是为什么呢?
//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变量,用来接收从数据库返回的详细内容。问题就是当我跳到显示详细内容的页面的时候却什么都没有,这是为什么呢?
解决方案 »
- 请教 泛型集合中的数据复制到另外的泛型集合中!!!!在线
- 服务器端动态添加checkbox控件后,“在服务器端”怎样判断它是否被选中?
- 请教如何在asp.net中应用socket向游戏服务器发送与接受数据。
- GridView自定义模版中添加了RadioButton控件,但RadioButton的CheckedChange()事件居然不好使了?
- 求《ASP.NET》揭密电子书和光盘文件
- 同样的程序,为何每台电脑的界面大小不一致呢?
- 如何改动程序可以使会话状态存储在外部进程中,而不存在w3wp.exe这个进程中???
- 因为不会,才虚心请教---怎样根据我的用户权限动态的改变框架的菜单(隐藏或者调换),菜单是ascx文件,菜单的一些链接及方法在javascrip
- jquery ui dialog问题
- “easyui-datebox”能不能设置只选择月份???
- 一个奇怪问题,请各高手帮助!
- 求救:SQL服务器老是自动暂停了
用ViewState["content"] = comm.Parameters["@NotContent"].Value.ToString();
第二个页面取ViewState["content"]值
我的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)
这个是不是对的啊?我总感觉是这个事件没有被击发...
comm.Parameters["@NotTitle"].Value=((LinkButton)sender).Text.ToString().Trim();
怎么才能把DATAGRID模板列中的LINKBUTTON控件的.Text属性取出来啊?
我想把它传给存储过程的参数,应该怎么做啊?