我如何从控件中获取TaskEventArgs

时间:2015-01-05 05:22:28

标签: asp.net vb.net events telerik

使用Telerik RadGantt图表。我需要使用给定的代码将事件插入数据库:

Private Sub RadGantt1_TaskUpdate(ByVal sender As Object, ByVal e As Telerik.Web.UI.Gantt.TaskEventArgs) Handles RadGantt1.TaskUpdate 
            mssql = "insert into project " & _
                    " (ParentID, OrderID, Title, Start, End, PercentComplete, Expanded, Summary)" & _
                    " values('E1','" & e.Tasks.GetEnumerator.Current.ID & "', " & _
                    " '" & e.Tasks.GetEnumerator.Current.Title & "'," & _
                    " '" & e.Tasks.GetEnumerator.Current.Start & "'," & _
                    " '" & e.Tasks.GetEnumerator.Current.End & "'," & _
                    " '" & e.Tasks.GetEnumerator.Current.PercentComplete & "'," & _
                    " '" & e.Tasks.GetEnumerator.Current.Expanded & "'," & _
                    " '" & e.Tasks.GetEnumerator.Current.Summary & "')"
            Dim mycommand As OdbcCommand
            mycommand = New OdbcCommand(mssql, dbcon)
            dbcon.Open()
            Dim mnresult As Integer = mycommand.ExecuteNonQuery()
            If mnresult = 1 Then
                EventAdd = False
            End If
         End Sub

但它在e.Tasks.GetEnumerator.Current.ID中给出了对象引用错误。那我怎么能从这个事件中获取价值?

1 个答案:

答案 0 :(得分:0)

e.Tasks是一个集合,所以你应该遍历它(例如,在for..each循环中)。

要获取可以读取其属性的单个任务,您应该使用集合的枚举器,例如e.Tasks(1).GetEnumerator.Current.ID