Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2004, 03:49 PM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hiding Divisions within a Repeater

Hello. I am attempting to create a Web form that displays data from a multi-table database in text boxes to allow the user to update and add to the current data. I set up a complicated SQL statement, created a DataSet and used a Repeater to produce a template that displays the data in a table complete with text labels for each data item returned from the database. It looks great.

Here's a piece of the Repeater in the form:
<asp:Repeater id="countyRepeater" runat="server">
<ItemTemplate>
<table summary="Payee Information" border="0">
<tr><td colspan="9" style="text-align:left"><b><asp:Label
   Text='<%# Container.DataItem("Collectable") %>'
   runat="server" /> for: </b><asp:TextBox
   Text='<%# Container.DataItem("EntityName") %>' size="60"
   runat="server" /></td></tr>
<tr><td style="text-align:right">Collected by: </td><td
   colspan="2"><asp:TextBox Text='<%# Container.DataItem("PayeeName")
   %>' size="35" runat="server" /></td></tr>
ETC...
</ItemTemplate>
</asp:repeater>


My problem revolves around figuring out how to place some logic in the template to hide irrelevant rows from the Web form. Some of the items I am displaying do not need to show tax information. So I created a division to go around those rows thinking I could set the visible property to false on those rows. Here's the division:

<div class="divTaxes" visible="true" runat="server">
<tr><td><b>Tax Information: </b></td><td style="text-align:right">Tax
   Rate: </td><td><asp:TextBox Text='<%# Container.DataItem
   ("TaxRate") %>' size="10" runat="server" /></td><td
   style="text-align:right">Tax Year Begins: </td><td><asp:TextBox
   Text='<%# Container.DataItem("TaxYearBegins") %>' size="10"
   runat="server" /></td></tr>
</div>

I believe I should set the visible value to true or false when the Repeater is writing a row. Or can this be done at the end of the Repeater's work right before the page is displayed? And how do I access the Repeater in this way?

Here is the code for the Repeater:

countyAdapter.Fill(countyDataSet)
countyRepeater.DataSource = countyDataSet
countyRepeater.DataBind()

(The criterion for displaying the tax information is the 'BodyType' field in the CollectableType table in the database. Only when the 'BodyType' = 'Taxing Body' would the tax data be displayed.)

Any advice would be greatly appreciated.

Dave

 
Old February 12th, 2004, 04:06 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Give this a try...

<tr runat="server" visible='<%# Container.DataItem("TaxRate") <> 0 %>'>
<td><b>Tax Information: </b></td><td style="text-align:right">Tax
   Rate: </td><td><asp:TextBox Text='<%# Container.DataItem
   ("TaxRate") %>' size="10" runat="server" /></td><td
   style="text-align:right">Tax Year Begins: </td><td><asp:TextBox
   Text='<%# Container.DataItem("TaxYearBegins") %>' size="10"
   runat="server" /></td>
</tr>

You may need to change the test in the data binding logic bit to suit your needs, but this is the general idea.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old February 12th, 2004, 04:41 PM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter,

Worked like a charm. Thank you.

Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding sub headers.... rupen Crystal Reports 6 May 14th, 2007 04:56 AM
Hiding Footer Arsi CSS Cascading Style Sheets 2 April 13th, 2007 06:55 PM
hiding footer. rupen Javascript How-To 4 April 12th, 2007 06:07 PM
Hiding scrollbars. rupen HTML Code Clinic 1 September 5th, 2005 07:00 AM
Hiding Keystrokes kromlic Beginning VB 6 3 June 12th, 2003 04:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.