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

Programmatically show/hide a table row

Status
Not open for further replies.

kipster

Technical User
Nov 26, 2001
12
0
0
GB
Hi all

I am developing an application in vb.net that allows a user to select a number of items via checkboxes, dropdown lists etc.

The results page needs to show the items selected by the user and the value for that selection in a table.

I can get all the items to show and if selected their value, but i need to be able to hide the name of the item selected and its value if it is not selected by the user.

Could someone please advise me how to do this?

Thanks in advance

Kevin

Code looks like this so far:
Input page
<tr>
<td>
Bathroom with W/C:</td>
<td>
<asp:CheckBox id="bathroom_with_wc" runat="server"></asp:CheckBox>
</td>
</tr>
<tr>
<td>
Separate Bathroom:</td>
<td>
<asp:CheckBox id="seperate_bathroom" runat="server"></asp:CheckBox>
</td>
</tr>
</tbody>
</table>
<p>
<asp:button id="calculatebutton" onclick="calculate" runat="server" text="calculate"></asp:button>
&nbsp;&nbsp;<asp:button id="resetbutton" runat="server" text="Reset"></asp:button>

Codebehind

' SimpleRent.vb
'

Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls


Namespace nihe

Public Class SimpleRent : inherits page
Public rentcalcSum as Integer
Public weeklyrent as double
Public rentpointvalue as double = 130.4

protected withevents bathroom_with_wc As system.web.ui.webcontrols.checkbox
protected withevents seperate_bathroom As system.web.ui.webcontrols.checkbox
protected withevents resetbutton As system.web.ui.webcontrols.button
protected withevents row_bathroom_with_wc As system.web.ui.webcontrols.TableRow
protected withevents row_seperate_bathroom As system.web.ui.webcontrols.TableRow

sub Page_Load

resetbutton.Attributes.Add(”onclick”, “JavaScript:document.forms[0].reset(); return false;“)

end sub

Public sub calculate(source as Object, e as EventArgs)

'process for collecting checkbox values
if bathroom_with_wc.checked then
rentcalcsum = rentcalcsum + 3
bathroom_with_wc.text = "+3"
Context.Items.Add("bathroom_with_wc", bathroom_with_wc.text)
row_bathroom_with_wc.Visible = bathroom_with_wc.checked

end if

if seperate_bathroom.checked then
rentcalcsum = rentcalcsum + 2
seperate_bathroom.text = "+2"
Context.Items.Add("seperate_bathroom", seperate_bathroom.text)
row_seperate_bathroom.Visible = seperate_bathroom.checked

end if

weeklyrent = rentcalcsum * rentpointvalue
weeklyrent = weeklyrent / 100
weeklyrent = Math.Round(weeklyrent, 2)

Context.Items.Add("weeklyrent", weeklyrent)

server.transfer("SimpleResult.aspx")

End Sub
End Class
End Namespace

Results page
<%@ Page Language="vb" %>
<script runat="server">

Sub Page_Load(Source as Object, E as EventArgs)
label1.text = "The weekly rent on this property would be £" & Context.Items("weeklyrent")
cell_bathroom_with_wc.text = "Bathroom with WC"
value_bathroom_with_wc.text = Context.Items("bathroom_with_wc")
cell_seperate_bathroom.text = "Seperate Bathroom"
value_seperate_bathroom.text = Context.Items("seperate_bathroom")
'
End Sub

</script>
<html>
<head>
<title>Rent Result Page</title>
</head>
<body>
<h3>Rent Calculator</h3>
<asp:Label id="label1" runat="server"></asp:Label>
<br />
<form>
<asp:Table borderwith="1" runat="server">
<asp:TableRow id="row_bathroom_with_wc" visible="false">
<asp:TableCell id="cell_bathroom_with_wc"></asp:TableCell>
<asp:TableCell id ="value_bathroom_with_wc"></asp:TableCell>
</asp:TableRow>
<asp:TableRow id="row_seperate_bathroom" visible="false">
<asp:TableCell id="cell_seperate_bathroom"></asp:TableCell>
<asp:TableCell id="value_seperate_bathroom"></asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>
 
I am confused by your post. Can you show and example of what the screen would look like and what the results would be?

I am not sure if you are asking to hide a row or a column.

Jim
 
Hi Jim

My intention is to build a table consisting of two columns and multiple rows on a results page.

Then dependent on what the user selects on the first page only show the rows for which the user has selected the items on the first page.

The first page will consist of various checkboxes, radio buttons and dropdown lists. The user selects those which apply to them and the results page should then only show the row for that item.

The following shows the output if the user has selected these items from the first page. Items not selected by the user are not shown (the results should be output in a table)

Feature Points
Accommodation Type + 12
Communal Facilities + 0
Heating Type - WHOLE HOUSE + 0
Heating Control + 1
Age of House + 1
Access Shared + 0
Access Independent + 0
Garage + 0
Total Points 14

I hope this clarifies things.

Thanks in advance

Kevin


 
You will have to create a sql statement to do this, preferably a Stored Procedure. You will then have to pass it any parameters necessary and construct the sql to pull only the data you want.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top