日期:2014-05-19  浏览次数:20356 次

datagrid和gridview的代码问题
protected   void   CommandHandle(object   sender,   GridViewCommandEventArgs   e)
        {
                if   (e.CommandName= "detail "){

                Response.Redirect( "ShowDetail.aspx?sid= "+e.Item.Cells(1).Text)
                  }

        }

以上是书上给的用datagrid实现的代码 我用gridview的时候   e.item.Cell(1).text出不来 请问因该改成什么啊?

------解决方案--------------------
那应该是e.Item.Cells(1).Text中没有值
------解决方案--------------------
顶一下
------解决方案--------------------
item改为Row,自己查查msdn,更详细一些~
------解决方案--------------------
不知道你拿DATAGRID的E.COMMANDNAME出来干什么 和你后边的问题有关系么????

e.Item.Cell[1].Text
必须是该CELL是标准绑定列或者成对的HTML标记

如果CELL里边是 <input type= "text " value= "ABCD " /> 这样类型的HTML代码是得不到值的
如果是 <input type= "text " > ABCD </input> 这样类型的可以得到ABCD
------解决方案--------------------
你用的是C#吧?
C#里是用方括号的  Cell[0]