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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeater Control and Subtotals 1

Status
Not open for further replies.

jkelly2956

Programmer
Jul 31, 2002
37
0
0
US
I have a dataset that I am displaying using a repeater control. I want to display a subtotal every ten records. How to do? Can you set the Footer row to show every ten records?
 
I don't think that you can. What you can do though is access the ItemDataBound event. You can set a page level variable and increment it every time an item is added. You can then use this counter to add your subtotal every ten rows.

James :)

James Culshaw
james@miniaturereview.co.uk
 
Ok I got it to print the subtotal. Now how do I access the value to check whether it is a subtotal...and change the style of that row...something like.

<ItemTemplate>
<% if Container.DataItem("Customer_ID") = "" then %>
<tr class="Main_Table" >
<% else %>
<tr class="SubTotal_Table" >
<% end if %>

This tells me that Container has not been declared.
 
Hello, I've a problem that could be solved if your problem is solved:
Which modification did you supply to these codelines to let it work?
I always receive (in a similar xase) an error "expression expected"

<ItemTemplate>
<%# if Container.DataItem("Customer_ID") = "" then %>
<tr class="Main_Table" >
<% else %>
<tr class="SubTotal_Table" >
<% end if %>

Thanks!
 
Basically I changed strategies and inside the code behind before I databind I added a column to the dataset called styleClass. Then I looped through the dataset and say

if CustomerID Field = "" THEN
styleClass field gets set to MainTable_Class
else
styleClass field gets set to SubTable_Class

then in the asp.net page I just say
<tr class="<%=Container.DataItem("styleClass")%>

In pages since ... I try to set the class styles in the query if I can...so I don't have to traverse the dataset. I can post some of the code if you like..

 
Thanks.
I just solved my problem by using "Iif" in steda of "If". So I handle this with an expression.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top