Sorry if the post is not in the right category.
I have som difficulty with an array that contains letters and rebinding it to properties, I'm pulling my hair and I need youre help.
If I bind it to a label i works fine
lblLessons.Text = education.lesson_a
But if I put the letter in an array and tries to rebind it to the properies nothing happens
Dim myArray As Char() = {"a", "b", "c"}
Dim i As Integer
For i = 0 To myArray.Length - 1
Dim currentLesson As Char = myArray(i)
Next i
Label1.Text = education.lesson_currentLesson
The label1 is not the real control, I would like to bind it to a ListBox
I don't have a whole lot of experience using arrays. I don't believe that arrays can be bound to controls such as listbox's, etc. If you are using .net 1.1, try using an arrayList, or if in .net 2.0, use a List(of T). You might have better luck.
Mark this post as the "Answer" if it was the answer.
Is it possible to rebind "currentLesson" with education.lesson_
Dim myArray As Char() = {"a", "b", "c"}
Dim i As Integer
For i = 0 To myArray.Length - 1
Dim currentLesson As Char = myArray(i)
Next i
Response.Write (education.lesson_currentLesson )
Dim myArray As Char() = {"a", "b", "c"}
Dim i As Integer
For i = 0 To myArray.Length - 1
Me.ListBox1.Items.Add(myArray(i).ToString())
Next
Me.ListBox1.DataBind()
Sincerely,
Samu Zhang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Jasbits
Member
99 Points
259 Posts
Array problems
Oct 24, 2007 06:29 PM|LINK
Hi everyone!
Sorry if the post is not in the right category.
I have som difficulty with an array that contains letters and rebinding it to properties, I'm pulling my hair and I need youre help.
If I bind it to a label i works fine
lblLessons.Text = education.lesson_a
But if I put the letter in an array and tries to rebind it to the properies nothing happens
Dim myArray As Char() = {"a", "b", "c"}
Dim i As Integer
For i = 0 To myArray.Length - 1
Dim currentLesson As Char = myArray(i)
Next i
Label1.Text = education.lesson_currentLesson
The label1 is not the real control, I would like to bind it to a ListBox
Thanks for youre answers
sswanner1
Contributor
2272 Points
492 Posts
Re: Array problems
Oct 24, 2007 06:56 PM|LINK
I don't have a whole lot of experience using arrays. I don't believe that arrays can be bound to controls such as listbox's, etc. If you are using .net 1.1, try using an arrayList, or if in .net 2.0, use a List(of T). You might have better luck.
Jasbits
Member
99 Points
259 Posts
Re: Array problems
Oct 24, 2007 09:33 PM|LINK
Okey, but if we just focus on loop
Is it possible to rebind "currentLesson" with education.lesson_
Dim myArray As Char() = {"a", "b", "c"}
Dim i As Integer
For i = 0 To myArray.Length - 1
Dim currentLesson As Char = myArray(i)
Next i
Response.Write (education.lesson_currentLesson )
Samu Zhang
Participant
982 Points
124 Posts
Re: Array problems
Oct 26, 2007 09:25 AM|LINK
Hi jasbits,
Try to use these codes:
Dim myArray As Char() = {"a", "b", "c"} Dim i As Integer For i = 0 To myArray.Length - 1 Me.ListBox1.Items.Add(myArray(i).ToString()) Next Me.ListBox1.DataBind()Samu Zhang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
sqlstuffload
Participant
1268 Points
188 Posts
Re: Array problems
Oct 26, 2007 10:24 AM|LINK
try this.
arraylist _al = new arraylist();
_al.items.add("A");
_al.items.add("B");
foreach(char _c in _al)
{
lblText.text = _c;
}
Cheers
Rammohan
Jasbits
Member
99 Points
259 Posts
Re: Array problems
Oct 27, 2007 02:54 PM|LINK
Works great!
Thanks alot,Samu Zhang!