I am using RadComboBox for ASP.NET AJAX
I am trying to set and retrieve a custom attribute for RadComboBoxes
I have successfully done this with a combobox wuthout loadondemand but I cannot get it to work with loadondemand.
I get the following error
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
|
Line 456 is the loadondemand RadComboBox which doesn't
I have looked at all the relevant forum posts and dowloaded the sample projects LOD_MultiColumn_CustomAttributes and LOD_MultiColumn_CustomAttributes_Web_UI
Here are some extracts of my code:
Protected Sub wcClinic_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles wcClinic.ItemsRequested
loadClinicItems(e.Text)
End Sub
Private Sub loadClinicItems(ByVal SearchText As String)
Dim Conn As SqlConnection
Dim ConnStr As String
If Session("Conn") Is Nothing Then
ConnStr = Application(
"CEDM_Connection")
Conn =
New System.Data.SqlClient.SqlConnection(ConnStr)
Session(
"Conn") = Conn
Conn.Open()
Else
Conn = Session(
"Conn")
If Conn.State = System.Data.ConnectionState.Closed Then Conn.Open()
End If
Dim sql As String = "SELECT Code,ClinicDescription,[Name] FROM [vw_Clinics] WHERE Code LIKE '" + SearchText + "%'"
Dim adapter As New System.Data.SqlClient.SqlDataAdapter(sql, Conn)
Dim dt As New DataTable()
adapter.Fill(dt)
Conn.Close()
wcClinic.DataSource = dt
wcClinic.DataBind()
End Sub
Protected Sub wcClinic_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemEventArgs) Handles wcClinic.ItemDataBound
Dim dr As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
e.Item.Value = dr(
"Code").ToString()
e.Item.Text = dr(
"ClinicDescription").ToString()
e.Item.Attributes(
"ClinicName") = dr("Name").ToString()
End Sub
BatchSettings.AuthorInitials = wcAuthor.SelectedItem.Attributes(
"AuthorInitials") 'This works
BatchSettings.DepartmentHeader = wcDeptHeader.Text
BatchSettings.ClinicName = wcClinic.SelectedItem.Attributes(
"ClinicName")'This throws an error
Any help would be much appreciated.