跟踪发现: Trim(e.Item.Cells(1).Text) 的值是正确的,但e.Item.Cells(0).Text的值则为'',第0列为模板列,是web代码错了吗,帮我改改吧,哪里错了,急啊!

解决方案 »

  1.   

    跟踪发现问题:e.Item.Cells(0).Text='',怎么会为空值    Private Sub grdLine_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdLine.DeleteCommand
            Dim strSqlDel As String
            strSqlDel = "delete from aLine_User_Temp where user_id='" & Trim(txtUser_Code.Text) & "' and line_code='" & Trim(e.Item.Cells(0).Text) & "'"  ???????why?????????        ExecuteSQL(strSqlDel)        grdLine.EditItemIndex = -1
            BindGridLine(strSqlLine, "tblLineUser")
        End Sub
      

  2.   

    因为你第0列为模版列,不能通过象e.Item.Cells[0]这样来取值.将第0列改为:
    <asp:label id="ShowCode" runat=server text='<%#  DataBinder.Eval(Container.DataItem, "customer_code") %>'></asp:label>在你的DeleteCommand中取Label值
    Label lb=(Label)e.Item.Cells[0].Controls[0];
    Response.Write(lb.Text):或者使用FindControl来查找控件,并取值
    Label lb=(Label)e.Item.FindControl("ShowCode");
    Resposne.Write(lb.Text);
      

  3.   

    真的如smilnet(笨笨) ( ) 说的吗,这样不行吗
      

  4.   

    是要(Label).e.Item.Cell[0].Controls[0].Text;