Gridview编译错误 [英] Gridview compilation Error

查看:85
本文介绍了Gridview编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在Gridview控件中遇到编译错误".下面是我的代码.
gv是gridview控件.请帮助我.

编译错误

说明:编译服务该请求所需的资源期间发生错误.请查看以下特定的错误详细信息,并适当地修改您的源代码.

编译器错误消息:BC30455:未为公共只读默认属性项(索引为Integer)作为System.Web.UI.WebControls.GridViewRow"的参数"index"指定参数.

源错误:
第18行:将myGridItem设置为DataGridItem
第19行:将myGridItem变暗为新的GridView
第20行:对于gv.Rows.Item
中的每个myGridItem 第21行:如果CType(myGridItem.Cells(0).Controls(0),CheckBox).Checked = True,则
第22行:cmd.Parameters.AddWithValue("@ UserName",Me.txtUserName.Text)


这是代码

Hi
I have a "Compilation Error" in Gridview control. Below is my code.
gv is gridview control. pls help Me.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30455: Argument not specified for parameter ''index'' of ''Public ReadOnly Default Property Item(index As Integer) As System.Web.UI.WebControls.GridViewRow''.

Source Error:
Line 18: ''Dim myGridItem As DataGridItem
Line 19: Dim myGridItem As New GridView
Line 20: For Each myGridItem In gv.Rows.Item
Line 21: If CType(myGridItem.Cells(0).Controls(0), CheckBox).Checked = True Then
Line 22: cmd.Parameters.AddWithValue("@UserName", Me.txtUserName.Text)


Here is code

Try
   Dim cmd As New SqlCommand("usp_UserRight_Insert", conn)
   cmd.CommandType = CommandType.StoredProcedure
   'Dim myGridItem As DataGridItem
   Dim myGridItem As New GridView
     For Each myGridItem In gv.Rows.Item
        If CType(myGridItem.Cells(0).Controls(0), CheckBox).Checked = True Then
           cmd.Parameters.AddWithValue("@MenuName", Me.gv.SelectedRow.Cells(1).Text)
           cmd.Parameters.AddWithValue("@MenuLink", Me.gv.SelectedRow.Cells(2).Text)
           Dim da As New SqlDataAdapter(cmd)
           Dim dt As New DataTable
           da.Fill(dt)
         End If
     Next
Catch ex As Exception
      MsgBox("Error:" & vbCrLf & ex.Message)
Finally
      conn.Close()
End Try



请帮我

谢谢
Maideen



Pls Help me

thanks
Maideen

推荐答案

If CType(myGridItem.Cells(0).Controls(0), CheckBox).Checked


应该是


should be

If CType(myGridItem.rows(0).FindControl("Controlname"), CheckBox).Checked


这篇关于Gridview编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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