Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeater - showing one set of data, in 2 columns

Status
Not open for further replies.

ggeorgiou01

Programmer
Joined
Apr 11, 2005
Messages
60
Location
GB
Hi all,

I have a repeater (show below).

<asp:repeater id="MyAppsRptr" runat="server">
<itemtemplate>
# DataBinder.Eval(Container, "DataItem.Description") %>
</ItemTemplate>
</asp:repeater>

which outputs onto a webpage like so...

1
2
3
4
5
6

How i want to display my data is in 2 columns... (i.e)

1 2
3 4
5 6

Is this easily done ?

Many Thanks,

George
 
Yes, it is. You have a few options.

1) Create a server Table Control and manually add the rows and columns
2) Use CSS and place the items in div tags (then use the Alternate Item to set different classes)
3) Use a standard table and use Alternate Item to set the relevant tr or td tags


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi, Thanks for your reply...

I have been trying to use your suggestion, number 3... But it seems that wherever i put the tr or td tags... it come out all weird...

Many Thanks,

George
 
Post the code you have been attempting...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Also, that's probably the hardest of the solutions to implement and personally I wouldn't use it.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I have sort of fixed it..... This is my code

<table>
<asp:repeater id="MyAppsRptr" runat="server">
<AlternatingItemTemplate>
<tr>
<td>
<a href='<%# DataBinder.Eval(Container, "DataItem.URL") %>' target="_blank"><%# DataBinder.Eval(Container, "DataItem.Description") %></a>
</td>
</AlternatingItemTemplate>
<ItemTemplate>
<td>
<a href='<%# DataBinder.Eval(Container, "DataItem.URL") %>' target="_blank"><%# DataBinder.Eval(Container, "DataItem.Description") %></a>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
</table>




but now i need to define the width... as it spans across the whole of the page. and adding the width attribut to the table, tr or td element... doesnt work !

Many Thanks,

George
 
What step would you use ???

Many Thanks,

George
 
Personally, I would have used option 1, but I guess it depends how flexible you need to be with the table (the code you have so far is perfectly fine if you are simply displaying the data and you don't need to manipulate it in any way).

As for the width, you should give the table (and also the "tr" and "td" tags if necessary) a class and then set it's design in a seperate CSS file.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for your responses, you've been a great help... i'll try that !

Many Thanks,

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top