473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to hide/show div in a nested repeater by clicking on a button inside parent repea

Hi guys

As per above question, the output I am getting at the moment, is my parent data displays along with my child data. However when I click on the button to toggle the views i am getting a "cannot cast type error"

I have also tried to put the itemdatabound event in my parent repeater tag, that worked but when I click on the buttons it just keeps moving to the top of the page and won't hide or show any of the child data except for the first child of the first parent. And thats after hiding data in the div tags, won't show the others but will show the top. Can anyone help?

Below is my current code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@Page Language="VB" EnableEventValidation="false"%>
  3. <%@Import Namespace="System.Data" %>
  4. <%@Import Namespace="System.Data.OleDb" %>
  5.  
  6. <script  runat="server">
  7.  
  8.     Dim ds As DataSet, divdtls, btnview, repeat
  9.  
  10.     Sub ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
  11.  
  12.         If e.Item.ItemType = ListItemType.Item Then
  13.             Dim divdtls As HtmlGenericControl = CType(e.Item.FindControl("details"), HtmlGenericControl)
  14.             Dim btnview As Button = CType(e.Item.FindControl("view"), Button)
  15.             'Dim repeat As Repeater = CType(e.Item.FindControl("achievements"), Repeater)
  16.             btnview.Attributes.Add("onclick", "javascript:displayAch(divdtls.ClientID)")
  17.             'regames.DataSource = cachedListOfT.FindAll(delegate(FooDetails match) Return match.FooId.Equals(foo.FooId))
  18.             'repeat.DataBind()
  19.         End If
  20.     End Sub
  21.  
  22.     Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
  23.         Dim daptGame As OleDbDataAdapter
  24.         Dim daptAch As OleDbDataAdapter
  25.         Dim dbconn As OleDbConnection
  26.  
  27.         dbconn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source=" & Server.MapPath("Xbox.accdb"))
  28.         dbconn.Open()
  29.         ds = New DataSet
  30.         daptGame = New OleDbDataAdapter("SELECT * FROM PctQuery ORDER BY Pct Desc, WonQuery_Achievements DESC, WonQuery_GamerScore DESC", dbconn)
  31.         daptAch = New OleDbDataAdapter("SELECT * FROM Achievements WHERE Won=True", dbconn)
  32.         daptGame.Fill(ds, "PctQuery")
  33.         daptAch.Fill(ds, "Achievements")
  34.         ds.Relations.Add("gameach", ds.Tables("PctQuery").Columns("ScoreQuery_Game"), ds.Tables("Achievements").Columns("Game"))
  35.         games.DataSource = ds.Tables("PctQuery")
  36.         games.DataBind()
  37.         dbconn.Close()
  38.  
  39.     End Sub
  40.  
  41.     Function CheckType(ByVal type As String)
  42.         If type = "Arcade" Then
  43.             Return "Arcade.png"
  44.         ElseIf type = "Retail" Then
  45.             Return "Retail.png"
  46.         ElseIf type = "Kinect" Then
  47.             Return "Kinect.png"
  48.         End If
  49.     End Function
  50.  
  51.     Function CheckPct(ByVal pct As String)
  52.         If pct = "100" Then
  53.             Return "lightgreen"
  54.         Else
  55.             Return "#f0f0f0"
  56.         End If
  57.     End Function
  58.  
  59.     Function UpperCase(ByVal upper As String)
  60.         Return UCase(upper)
  61.     End Function
  62.  
  63.  
  64. </script>
  65.  
  66. <html>
  67. <body>
  68.  
  69. <script type="text/javascript">
  70.  
  71.     function displayAch(repeaterID) {
  72.  
  73.         var element = document.getElementById(repeaterID).style.display
  74.         if (element == 'none') {
  75.             element = 'block';
  76.         }
  77.         else {
  78.             element = 'none';
  79.         }
  80.     }
  81. </script>
  82.  
  83. <form id="Form1" runat="server">
  84. <asp:Repeater id="games" runat="server">
  85.  
  86. <HeaderTemplate>
  87. <table border="0" width="100%" bordercolor=black>
  88. <tr bgcolor="#F0F0F0">
  89. <th></th>
  90. <th align=left><font face="Calibri" size=3>&nbsp;&nbsp;&nbsp;GAME</font></th>
  91. <th align=right><font face="Calibri" size=3>ACHIEVEMENTS&nbsp;&nbsp;&nbsp;</font></th>
  92. <th align=right><font face="Calibri" size=3>GAMERSCORE&nbsp;&nbsp;&nbsp;</font></th>
  93. <th align=right><font face="Calibri" size=3>%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></th>
  94. </tr>
  95. </HeaderTemplate>
  96.  
  97. <ItemTemplate>
  98.  
  99. <tr align=center bgcolor="#D8DEE9">
  100. <td width=30><br>&nbsp;&nbsp;<asp:Button id="view" Text="View" runat="server" OnClick="ItemDataBound" AutoPostBack=True />
  101. <b><img src="<%# Container.DataItem("ScoreQuery_Game")%>.jpg"></b></td>
  102. <td width=400 align=left><font face="Calibri" size=5>&nbsp;&nbsp;<b><%# UpperCase(Container.DataItem("ScoreQuery_Game"))%> </b></td>
  103. <td width=100 align=right><font face="Calibri" size=5><b><%# Container.DataItem("WonQuery_Achievements")%> / <%# Container.DataItem("ScoreQuery_Achievements")%></b>&nbsp;<img src="Trophy.png">&nbsp;&nbsp;</td>
  104. <td width=150 align=right><font face="Calibri" size=5><b><%# Container.DataItem("WonQuery_GamerScore")%> / <%# Container.DataItem("ScoreQuery_GamerScore")%></b>&nbsp;<img src="Glyph.png">&nbsp;&nbsp;</td>
  105. <td width=150 background=<%# CheckType(Container.DataItem("Type"))%> align=right><font face="Calibri" size=10 color=white><B><%# CUInt(Container.DataItem("Pct"))%></B>&nbsp;&nbsp;</td>
  106. </tr>
  107.  
  108. <div id="details" runat="server" style="display:none">
  109. <asp:Repeater id="achievements" runat="server" datasource=<%# CType(Container.DataItem, DataRowView).Row.GetChildRows("gameach")%>>
  110.  
  111. <HeaderTemplate>
  112. <table border="0" width="100%" bordercolor=black>
  113. </HeaderTemplate>
  114.  
  115. <ItemTemplate>
  116.  
  117. <tr>
  118. <td>&nbsp;</td>
  119. <td width=400 align=left><font face="Calibri" size=3>&nbsp;&nbsp;&nbsp;<b><%# Container.DataItem("Achievement")%></b></td>
  120. <td width=100 align=right><font face="Calibri" size=3><b><%# Container.DataItem("Gamerscore")%></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  121. <td></td>
  122. <td></td>
  123. </tr>
  124.  
  125. </ItemTemplate>
  126.  
  127. <FooterTemplate>
  128. </table>
  129. </FooterTemplate>
  130.  
  131. </asp:Repeater>
  132.  
  133. </div>
  134. </ItemTemplate>
  135.  
  136. <FooterTemplate>
  137. </table>
  138. </FooterTemplate>
  139.  
  140. </asp:Repeater>
  141.  
  142. </form>
  143.  
  144.  
  145. </body>
  146. </html>
  147.  
Nov 12 '10 #1
1 6715
Frinavale
9,735 Expert Mod 8TB
I don't have time right now to read through all of the code you've posted (you really should consider using CSS) but I have a feeling that you may be interested in checking out what I have done in this JavaScript snippet I've posted here: Show/Hide columns

I know that that snippet shows/hides columns and you're not looking to do that...

So you might also be interested in checking out my reply to this thread here:Expand/Collapse GridView ChildView

-Frinny
Nov 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tommy | last post by:
I have been working on getting nested repeaters to work for several days. When I add a repeater inside my item template i cannot see it in my code and can't set the datasource for it, etc, thus...
0
by: BG | last post by:
Is it possible to get a value from the parent repeater from within a child nested repeater? Here is an example of what I want to do, but can't figure out how or if it's possible at all: ...
0
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
1
by: Maziar Aflatoun | last post by:
Hi, I have tried setting up a nested repeater control and it works fine. But when I do 3 level nested repeater it fails. Does anyone know a site or have an example of a three level nestest...
3
by: sorCrer | last post by:
Hi All, Posted after extensive searching! I have a nested repeater control as follows: (Simplified ;-)) <table> <asp:repeater id=parent onItemDataBound=createChild> <tr><td>Level...
2
by: mark | last post by:
(not sure if this is the correct group) My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater...
0
by: bdtmike | last post by:
I'm trying to set up a nested repeater to display master/child data. To do this I'm using 2 repeater controls and I'm using 2 SQLDataSource controls. I'm clear on embeding one repeater inside the...
2
by: mavrick_101 | last post by:
Hi, I have a nested repeater. For each row in the parent repeater there is a child repeater with several rows of data. The way I'm doing this is throught ItemDataBound Event. So for each Row...
1
by: bob8000 | last post by:
Hello everyone, I am completly new to ASP.NET and I am attempting to design a web site with it and VB.NET I have been following an example from a book which as taken me to the point where I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.