I have a Listbox on my page which I add RadListBoxitems to on page.load , however when I try read these items from a button.click event they disappear. I can add the items back on page.load but this wont solve the problem as the items the user selected are lost. I guess this is more of an ASP.NET issue but I am stumped as to how I should solve it (I enabled viewstate and presistclientchanges but with no luck).
aspx code:
code behind:
Thanks
aspx code:
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadListBox ID="RadListBox1" runat="server" Style="left: 0px; top: 0px" EnableViewState="true" |
| ButtonSettings-ShowTransferAll="False" CheckBoxes="True"> |
| <ButtonSettings ShowTransferAll="False" /> |
| </telerik:RadListBox> |
| <asp:Button ID="submitBtn" runat="server" Text="Submit" /> |
code behind:
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| If Not Page.IsPostBack Then |
| populateUserListing() |
| End If |
| End Sub |
| Protected Sub submitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitBtn.Click |
| For i As Integer = 0 To RadListBox1.Items.Count - 1 |
| If RadListBox1.Items(i).Checked Then |
| 'do actions here |
| End If |
| Next |
| End Sub |
| Sub populateUserListing() |
| For i As Integer = 0 To item.Count - 1 |
| Dim dummyListItem As New RadListBoxItem("xxx", "xxx") |
| RadListBox1.Items.Add(dummyListItem) |
| Next |
| End Sub |
Thanks