当前位置: 代码迷 >> ASP.NET >> 帮小弟我看看这段代码把,有什么东东
  详细解决方案

帮小弟我看看这段代码把,有什么东东

热度:4284   发布时间:2013-02-25 00:00:00.0
帮我看看这段代码把,有什么错误?
if(e.CommandName== "id_link ")
{
string   id=e.Item.Cells[3].Text.Trim();
if(this.Session[ "id "]==null)
{
this.Response.Write( " <script> alert( '请先登陆 ') </script> ");
}
else   if(this.Session[ "id "].ToString().Trim()==id)
{
this.Response.Redirect( "my_user_control.aspx ");
}
else
{
this.Response.Redirect( "user_control.aspx?id= "+id+ " ");
}
}

------解决方案--------------------------------------------------------
没什么问题吧
------解决方案--------------------------------------------------------
报什么错误啊..
------解决方案--------------------------------------------------------
程序运行有什么问题,打个断点调试一下,有可能是e.Item.Cells[3].Text.Trim()没值
------解决方案--------------------------------------------------------
那你可能用了模版列,要取模版里面控件的值才行

string id = e.Item.Cells[3].FindControl( "txt_ID ").Text.Trim();

txt_ID是模版列里面控件的id
------解决方案--------------------------------------------------------
sorry ,

e.Item.Cells[3].FindControl( "txt_ID ").Text.Trim(); 这种写法如果c#不支持的话可以

((LinkButton)e.Item.Cells[3].FindControl( "txt_ID ")).Text.Trim();
  相关解决方案