“行"不是DataGrid的成员.导入时 [英] 'Rows' is not a member of DataGrid'. While Import

查看:78
本文介绍了“行"不是DataGrid的成员.导入时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我正在将GridView2.Rows(i).Cells(3).Textreader(0)进行比较,但出现错误.

Here I am comparing GridView2.Rows(i).Cells(3).Text with reader(0), but I am getting an error.

Public Sub checkpipno()
        Dim i As Integer
        For i = 0 To GridView1.Rows.Count - 1
            Dim vr As String
            vr = GridView2.Rows(i).Cells(5).Text
            Dim village As String = GridView2.Rows(i).Cells(3).Text
            Dim con As New SqlConnection(connStr)
            con.Open()
            Dim sql As String = "SELECT pipno,pipcode1 FROM PIP_Entry WHERE Rpt_Unit = '" & village & "' "
            Dim cmd As New SqlCommand(sql, con)
            Dim reader As SqlDataReader = cmd.ExecuteReader()
            While reader.Read()
                If vr = reader(0).ToString() Then
                    GridView2.Rows(i).Cells(14).Text = reader(1).ToString()
                    GridView2.Rows(i).Cells(14).BackColor = System.Drawing.Color.FromName("Green")
                    GridView2.Rows(i).Cells(15).Text = "Done"
                    GridView2.Rows(i).Cells(15).BackColor = System.Drawing.Color.FromName("Green")
                End If
            End While
            reader.Close()
            con.Close()
        Next
    End Sub


上面的代码我用来比较网格视图行与其他表值,即reader(0)中的值,但是在这里我在VB.NET中遇到错误.


The Above Code I have used to compare grid view row with other table value i.e., in reader(0), but here I am getting error in VB.NET.

'Rows' is not a member of 'System.Web.UI.WebControls.DataGrid'.


此帖子的发布解决方案


Post Solution for this Post

推荐答案

该错误已清除. Datagrid [ Gridview [^
The error is clear. Datagrid[^] has now member called Rows. Verify Gridview1 and Gridview2 if they are really Gridview[^] controls or not.


DataGrid控件具有Items属性,以编程方式访问该控件中的项目.此处给出了访问DataGrid每行的单个单元格中的值的示例.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.items.aspx [
The DataGrid control has an Items property to programmatically access the items in the control. An example to access the values in individual cells of each row of DataGrid is given here.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.items.aspx[^]

You may vote and accept the solution if your problem is solved, otherwise please post your queries.


这篇关于“行"不是DataGrid的成员.导入时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆