ITPUB??ì3
ITPUB论坛 » Web开发 » ASP.NET与AJAX » Gridview 的web user control的编译问题,附代码

标题: Gridview 的web user control的编译问题,附代码
离线 marry1986
老会员



精华贴数 0
个人空间 0
技术积分 2060 (881)
社区积分 1 (48277)
注册日期 2007-6-21
论坛徽章:4
设计板块每日发贴之星设计板块每日发贴之星设计板块每日发贴之星开发板块每日发贴之星  
      

发表于 2007-7-16 08:39 
Gridview 的web user control的编译问题,附代码

代码如下:

Imports Microsoft.VisualBasic
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel

Partial Class bulkedit
    Inherits System.Web.UI.WebControls.GridView

    Protected Overrides Function CreateRow(ByVal rowIndex As Integer, ByVal dataSourceIndex As Integer, ByVal rowType As System.Web.UI.WebControls.DataControlRowType, ByVal rowState As System.Web.UI.WebControls.DataControlRowState) As System.Web.UI.WebControls.GridViewRow
        Return MyBase.CreateRow(rowIndex, dataSourceIndex, rowType, DataControlRowState.Edit)
    End Function

    <IDReferenceProperty(GetType(Control))> _
    Public Property SaveButtonID() As String
        Get
            Dim val As String = Me.ViewState("SaveButtonID"
            If val = Nothing Then
                Return String.Empty
            Else
                Return val
            End If
        End Get
        Set(ByVal value As String)
            Me.ViewState("SaveButtonID" = value
        End Set
    End Property

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        MyBase.OnLoad(e)
        If Me.SaveButtonID.ToString <> String.Empty Then
            Dim btn As Control = RecursiveFindControl(Me.NamingContainer, Me.SaveButtonID)
            If btn IsNot Nothing Then
                If TypeOf (btn) Is Button Then
                    AddHandler CType(btn, Button).Click, AddressOf SaveClicked
                ElseIf TypeOf (btn) Is LinkButton Then
                    AddHandler CType(btn, LinkButton).Click, AddressOf SaveClicked
                ElseIf TypeOf (btn) Is ImageButton Then
                    'AddHandler CType(btn, ImageButton).Click, AddressOf SaveClicked
                End If

            End If
        End If
    End Sub
    Protected Overrides Sub InitializeRow(ByVal row As System.Web.UI.WebControls.GridViewRow, ByVal fields() As System.Web.UI.WebControls.DataControlField)
        MyBase.InitializeRow(row, fields)
        For Each cell As DataControlFieldCell In row.Cells
            If cell.Controls.Count > 0 Then
                AddChangeHandler(cell.Controls)
            End If
        Next
    End Sub

    Private Sub AddChangeHandler(ByVal controls As ControlCollection)
        For Each ctrl As Control In controls
            If TypeOf (ctrl) Is TextBox Then
                AddHandler CType(ctrl, TextBox).TextChanged, AddressOf handleRowChanged
            ElseIf TypeOf (ctrl) Is DropDownList Then
                AddHandler CType(ctrl, DropDownList).SelectedIndexChanged, AddressOf handleRowChanged
            ElseIf TypeOf (ctrl) Is CheckBox Then
                AddHandler CType(ctrl, CheckBox).CheckedChanged, AddressOf handleRowChanged
            End If
        Next
    End Sub
    Sub handleRowChanged(ByVal sender As Object, ByVal args As EventArgs)
        Dim row As GridViewRow = CType(sender, Control).NamingContainer
        If row IsNot Nothing And Not dirtyRows.Contains(row.RowIndex) Then
            dirtyRows.Add(row.RowIndex)
        End If
    End Sub

    Private dirtyRows As New System.Collections.Generic.List(Of Integer)
    Public Sub save()
        For Each row As Integer In dirtyRows
            Me.UpdateRow(row, False)
        Next
        dirtyRows.Clear()
    End Sub
    Private Sub SaveClicked(ByVal sender As Object, ByVal e As System.EventArgs)
        Me.save()
        Me.DataBind()
    End Sub

    Private Function RecursiveFindControl(ByVal root As Control, ByVal id As String) As Control
        If root.ID = id Then
            Return root
        End If
        For Each c As Control In root.Controls
            Dim t As Control = RecursiveFindControl(c, id)
            If t IsNot Nothing Then
                Return t
            End If
        Next
        Return Nothing
    End Function


End Class

--------------------

错误信息如下:

Error1'ReadStringResource' is not a member of 'ASP.bulkeditgridview_ascx'.C:\Documents and Settings\jimmybai\Local Settings\Temp\Temporary ASP.NET Files\cip\a62ce21d\a6805e18\App_Web__xv5fhem.7.vb66


Error1property 'SupportAutoEvents' cannot be declared 'Overrides' because it does not override a property in a base class.C:\Documents and Settings\jimmybai\Local Settings\Temp\Temporary ASP.NET Files\cip\a62ce21d\a6805e18\App_Web_jyvfzmz1.0.vb68

啥问题引起的?

这是有关这些代码的介绍:
http://blogs.msdn.com/mattdotson/articles/490868.aspx


为啥编译时出错呢?那有问题?


只看该作者    顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰网域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:060528号 联系我们 法律顾问