We help IT Professionals succeed at work.

Displaying data horizontally

ayha1999
ayha1999 asked
on
Is there any way to display data horizontally in asp.net?

I have the following data

dim sArray() as integer = {1,2,3,4,5}
dim sArray2 as integer = {1,2,3,4,5,6,7,8,9,10}

I want to display it as follows and read it from the control. please give a sample.

 1,2,3,4,5
 1,2,3,4,5,6,7,8,9,10

Please help

Thanks

ayha
Comment
Watch Question

Kiran SonawaneProject Lead
Top Expert 2011

Commented:
You can convert array into string like this

string your_string = String.Join(", ", sArray);

Response.Write(your_string);// output 1,2,3,4,5

Author

Commented:
First I want bind it to any asp.net control horizontally.

Kiran SonawaneProject Lead
Top Expert 2011

Commented:
which asp.net control you want to bind

Author

Commented:
any control but need to display data horizontally

thanks
Kiran SonawaneProject Lead
Top Expert 2011

Commented:
aspx

<asp:Label id="label1" runat="server" />

aspx.cs

dim sArray() as integer = {1,2,3,4,5}
label1.Text= String.Join(", ", sArray)

Author

Commented:
sorry sonawanekiran. I mean any data controls like datagridview, repeater etc.
Kiran SonawaneProject Lead
Top Expert 2011

Commented:
You can make it work like this

Dim coma_sep_list As ArrayList
coma_sep_list.Add (String.Join(", ", sArray))
coma_sep_list.Add (String.Join(", ", sArray2))

rpt.DataSource = coma_sep_list
rpt.DataBind()

Author

Commented:
but this bind vertically,right?
Project Lead
Top Expert 2011
Commented:
This will display data like

1,2,3,4,5
1,2,3,4,5,6,7,8,9,10

Do you want to display data like below?

1,2,3,4,5        1,2,3,4,5,6,7,8,9,10

Author

Commented:
what is value for the <%# DataBinder.Eval(Container.DataItem, "?")%>?

 <asp:Repeater ID="Repeater2" runat="server">
    </asp:Repeater>