-2

I'm getting data into my code behind file in the format of array list. The sproc will return several records depending upon the input parameter value. Now i need to display all these values in HTML as labels dynamically.

For example if i got 2 records, i just need to display those 2 records, if 10 records are returned then display 10 records. I don't want keep 10 static labels to bind all the time. I just looking to place only one label in html and want to use that one to display all the records returned by query. Will it be possible??

Sample code:

//Client side
<asp:Label ID="lblresult" runat="server" CssClass="label" ></asp:Label>

//server side

     Dim arraylist as arrayList = //result from sproc                   
                Dim lbltext As String = ""        
                For Each item In arraylist        
                    Do While item.value = lbltext
                        Me.lblresult.Text = item.value
                        lbltext = item.value        
                    Loop                       
                Next                  

Please let me how to solve this? Thanks in advance!

Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
John K
  • 3
  • 2
  • Maybe you should see the [GridView](http://quickstarts.asp.net/quickstartv20/aspnet/doc/ctrlref/data/gridview.aspx) control – Rubens Farias Aug 12 '16 at 19:09
  • What you really want? In first part of question you ask to create labels dynamically (so, that's mean for each record you want label) and in second part of question you ask how to store all records in one label... if you want all records in that one label then use `lblresult.Text += item.value.ToString() +vbCrLf` and if you want separately label for each record then, by my suggestion, use ` – nelek Aug 12 '16 at 19:10

2 Answers2

0

Kinda late for this, but is this what you are looking for?

        For i = 0 To YourArrayList.Count - 1
            lblresult.Text &= YourArrayList(i).ToString & " "
        Next

Also this will cause you an error:

        Dim arraylist as arrayList = //result from sproc

arraylist is a reserved keyword. You might want to use another name.

Aethan
  • 1,986
  • 2
  • 18
  • 25
-2

You can try following technique which i often use in C#,Php etc: hope this will give you an idea for doing it in your programming Language.

string rows;
for(int cnt=0;cnt<array.count;cnt++) {
    rows = rows +""+array[cnt].value;
}
yourLable.text = rows; //here you are binding all your rows to your lable
Alex B.
  • 2,145
  • 1
  • 16
  • 24