Getting ReorderList Item Values

by JoeStagner 5/25/2007 4:08:22 PM

I customer email me asking how to iterate the values of items in the AJAX Control Toolkit ReorderList Sample.

Thanks to Shawn Burke for the hints. 

Here is how you get to them.

Assuming an Item template that includes 2 label controls…..

 

    1     Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

    2         Dim l1, l2 As Label

    3         Dim i, max As Integer

    4 

    5         Label3.Text = ""

    6         max = ReorderList1.Items.Count - 2

    7         For i = 0 To max

    8             l1 = CType(ReorderList1.Items(i).FindControl("Label1"), Label)

   09             l2 = CType(ReorderList1.Items(i).FindControl("Label2"), Label)

   10             Label3.Text = Label3.Text + "  " + l1.Text + "  " + l2.Text + "<br />"

   11         Next i

   12     End Sub

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Related posts

Comments

10/6/2007 7:53:44 PM

Hi Joe -

I am trying to put a text box in a reorder list Item Teplate and then retrive the text when the operator clicks a button. Here is the issue.

ReorderList1.Items(i) - I get an syntax error when indexing Items on a ReorderList1...

AjaxControlToolkit.ReorderList.Items' is a 'property' but is used like a 'method'

Thanks,

Jerome

Jerome Vernon

11/5/2007 7:58:34 AM

Jerome,

You are probably using C#. That code is VB code, and in VB arrays are accessed through parens. The C# code would be more like:

ReorderList1.Items[i]

John Varga

1/9/2008 7:52:50 AM

The above example works fine of the list is not reordered when called.
Example: We have 3 items; A-B-C; in that order. A is 0, B is 1, C is 2.
We now move B from the #1 spot to the #0 spot, so we have B-A-C.
When the above code is called, and you loop through the list, when accessed {CType(ReorderList1.Items(i).FindControl("Label1"), Label)}, and "i" is zero (0), the "i" variable is pointing to A, not to B.

Gary Noter

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About your host.

Name of author Joe Stagner
?????

E-mail me Send mail

Calendar

<<  September 2008  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

View posts in large calendar

Pages

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in