日期:2014-05-18  浏览次数:20406 次

帮我看看这段代码把,有什么错误?
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();