This is a migrated thread and some comments may be shown as answers.

[Solved] keep selected value in session

3 Answers 155 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
casa51
Top achievements
Rank 2
casa51 asked on 05 Oct 2009, 06:02 AM
hi i use for test your
ComboBox / Related ComboBoxes exemple
all work perfectly but now i tri tu put in session the value off the 3 combobox
the 1 work perfectly but the other do this message :
System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.

my code :

 

Protected Sub Loadvoiture()

 

Dim connection As SqlConnection = CreateConnection()

 

 

 

Dim adapter As New SqlDataAdapter("SELECT * FROM MAKE ORDER By Make", connection)

 

 

 

Dim dt As New DataTable()

 

 

adapter.Fill(dt)

RadComboBox1.DataTextField =

 

"Make"

 

RadComboBox1.DataValueField =

 

 

"Makecode"

 

 

RadComboBox1.DataSource = dt

RadComboBox1.DataBind()

 

'insert the first item

 

 

RadComboBox1.Items.Insert(0,

New RadComboBoxItem("- Slectionnez une marquent -"))

 

 

End Sub

 

 

Protected Sub LoadModele(ByVal MakecodeID As String)

 

 

 

Dim connection As SqlConnection = CreateConnection()

 

 

 

Dim adapter As New SqlDataAdapter("SELECT * FROM MODEL WHERE Makecode=@Makecode ORDER By Model asc", connection)

 

 

adapter.SelectCommand.Parameters.AddWithValue(

 

"@Makecode", MakecodeID)

 

 

 

Dim dt As New DataTable()

 adapter.Fill(dt)

 

For Each row As DataRow In dt.Rows

 

 

 

Dim item As New RadComboBoxItem()

 

 

 tem.Text = row(

 

"Model").ToString() & " ( " & row("Model_Year_From").ToString() & " - " & row("Model_Year_Till").ToString() & " ) "

 

item.Value = row(

 

 

"ModelCode").ToString()

 

RadComboBox2.Items.Add(item)

 

Next

 

 

 

End Sub

 

 

 

 

 

Protected Sub LoadType(ByVal ModelCodeID As String)

 

Dim connection As SqlConnection = CreateConnection()

 

 

 

Dim adapter As New SqlDataAdapter("SELECT * FROM TYPE WHERE ModelCode=@ModelCode ORDER By ModelCode", connection)

 

 

 adapter.SelectCommand.Parameters.AddWithValue(

 

"@Modelcode", ModelCodeID)

 

 

Dim dt As New DataTable()

 

 

adapter.Fill(dt)

RadComboBox3.DataTextField =

 

"Type"

 

 

RadComboBox3.DataValueField =

"TypeCode"

 

RadComboBox3.DataSource = dt

 

RadComboBox3.DataBind()

 

End Sub

 

 

 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

'------------------------after this WORK
Session(

"marque") = RadComboBox1.SelectedItem.Text

 

Session(

"marqueID") = RadComboBox1.SelectedItem.Value 


'------------------------after this NOT WORK

 

Session(

"modelev") = RadComboBox2.SelectedItem.Text     

 

Session(

"modelevID") = RadComboBox2.SelectedItem.Value

 

Session(

"typev") = RadComboBox3.SelectedItem.Text

 

Session(

"typevID") = RadComboBox3.SelectedItem.Value

 

  

 

End Sub


this code not work impossible to put the selected value of RadComboBox2 and RadComboBox3 in session
why ? the first RadComboBox1 session work perfectly !

Thanks for you help

3 Answers, 1 is accepted

Sort by
0
casa51
Top achievements
Rank 2
answered on 06 Oct 2009, 02:00 PM
Hi
I don t found any soluce on my problem
with this exemples :
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx

when all radcombobox a selected
how to access to the value off radcombobox2 and radcombobox3 in codebehind
I need this to transfert this value to an other page

thanks
0
Accepted
Yana
Telerik team
answered on 07 Oct 2009, 10:32 AM
Hello there,

Please use SelectedValue and Text properties of the combobox in order to get the value and text of the loaded on demand items.

Best wishes,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
casa51
Top achievements
Rank 2
answered on 07 Oct 2009, 10:38 AM
THanks they work nicely !!!
Tags
ComboBox
Asked by
casa51
Top achievements
Rank 2
Answers by
casa51
Top achievements
Rank 2
Yana
Telerik team
Share this question
or