Dim i As Integer = CType(e.CommandArgument, Integer)
        Dim strsql As String = "delete * from users where userid=" & i.ToString()

解决方案 »

  1.   


    教学例子里是ctype(e.item.cells(0).controls(0),textbox).text 
    '但是运行后提示:无法将类型为“System.Web.UI.LiteralControl”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”。该怎么办呢?

     
    <asp:Label   ID="lblid"   runat="server" 
      text=' <%#   container.dataitem("userid")   %> '   /> 
    你用的Label   
    改为CType(e.Item.Cells(0).Controls(0), Label).Text
      

  2.   

    ctype(e.item.cells(0).controls(0),textbox).text 
    textbox修改成你需要的控件
      

  3.   

    还有一个问题,你这条查找语句应该放在ItemDataBound事件里,不能放在page_load里因为CType(e.Item.Cells(0).Controls(0), Label).Text中的e不匹配,你考虑考虑.
      

  4.   

    感谢Sandy945 hy_lihuan 。
    还是没仔细看,呵呵。
    除了改为
    ctype(e.item.cells(0).controls(0),label).text
    还要改为
    ctype(e.item.cells(0).controls(1),label).text