Re: NullReference when customizing Links ddl

  •  01-25-2006, 3:09 PM

    Re: NullReference when customizing Links ddl

    Here it is:

    Protected Sub Editor1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Editor1.Load
            Dim connstr As ConnectionStringSettingsCollection = ConfigurationManager.ConnectionStrings
            Dim sqlConn As New SqlConnection(connstr("SRHSWeb").ConnectionString)
            Dim strsql As String
            Dim cmd As SqlCommand
            Dim objRead As SqlDataReader
            Dim titlefld As String
            sqlConn.Open()
            If editpageid > 0 Then
                strsql = "select body,versiontitle,title,right_content from editpages where id = " & Session("editpageid")
                titlefld = "versiontitle"
            Else
                strsql = "select body,title,right_content from pages where id = " & Session("pageid")
                titlefld = "title"
            End If
            cmd = New SqlCommand(strsql, sqlConn)
            objRead = cmd.ExecuteReader
            If objRead.HasRows Then
                objRead.Read()
                Editor1.Text = objRead("body").ToString()
                VersionTitle.Text = objRead(titlefld).ToString()
                pageTitle.Text = objRead("title").ToString()
                Editor2.Text = objRead("right_content").ToString
            End If
            objRead.Close()
            cmd.Dispose()
            strsql = "select * from pages"
            cmd = New SqlCommand(strsql, sqlConn)
            objRead = cmd.ExecuteReader
            Dim tdd As CuteEditor.TreeDropDownList
            tdd = DirectCast(Editor1.ToolControls("LinkTree").Control, CuteEditor.TreeDropDownList)
            tdd.Items.Clear()
            While objRead.Read()
                Dim rootitem As CuteEditor.TreeListItem
                rootitem = New CuteEditor.TreeListItem(objRead("title").ToString, objRead("title").ToString, "~/default.aspx?pageid=" & objRead("id"))
                tdd.Items.Add(rootitem)
            End While
            objRead.Close()
     
            sqlConn.Close()
        End Sub
View Complete Thread