473,725 Members | 2,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide / Show Panels through a Repeater

Hi Everyone,

I am pretty new to coding in .net and need some help in showing and
hiding information from a repeater control. I am calling a list of
FAQ's from a Database and display both the question and answer. What i
would like to happen is to display the list of questions and when the
user clicks on one of them, the answer appears below.

There are about 50 or so FAQ's, so I don't really want to use the
Javascript of Show/Hide div's as was previously used. And these FAQ's
appear on about 7 sites, so I am trying to save myself from coding
several different pages for one FAQ change. What I have so in my code
behind is:
SqlConnection myConnection = new
SqlConnection(" server=IP;uid=u ser;pwd=passwor d;database=valu e");
SqlDataAdapter myCommand = new SqlDataAdapter( "SELECT * from FAQ",
myConnection);
DataSet ds = new DataSet();
myCommand.Fill( ds);
rptQuestions.Da taSource = ds;
rptQuestions.Da taBind();

and my repeater is simply inserted as:
<asp:Repeater ID="rptQuestion s" runat="server">
<ItemTemplate >
<p><b><%# DataBinder.Eval (Container.Data Item, "FAQ_Questi on") %></b><br
/>
<%# DataBinder.Eval (Container.Data Item, "FAQ_Answer ") %></p><br />
</ItemTemplate>
</asp:Repeater>

All this does is just display the questions and answers in paragraph
format. Any help would be appreciated.

THANKS!

Sep 8 '06 #1
1 2933
<asp:Repeater ID="rptQuestion s" runat="server">
<ItemTemplate >
<table>
<tr>
<td>
<b><%# DataBinder.Eval (Container.Data Item, "FAQ_Question") ></b>
</td>
<td><a href="#" onclick="toggle Question('<%#
DataBinder.Eval (Container.Data Item, "FAQ_ID")>')">S how answer</a></td>
</tr>
<tr><td colspan="2">
<div style="display: none" id='<%# DataBinder.Eval (Container.Data Item,
"FAQ_ID")>' ><%# DataBinder.Eval (Container.Data Item, "FAQ_Answer ") %>
</div>
</td></tr>
</table>
</ItemTemplate>
</asp:Repeater>

<script>
function toggleQuestion( id) {
var elem = document.getEle mentById(id);
elem.styles.dis play = elem.styles.dis play=="none"?"b lock":"none";
}
</script>

Regars,
Tasos

Sep 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
15669
by: Jerad Rose | last post by:
I searched for a while trying to find the answer to this, but to no avail. I am trying to find the best way (or any way) to dynamically show and hide groups of TR's. For example, I have a section of about 6 table rows that all need to be hidden if a certain condition is met. But I don't want to hide the whole table. And, I don't want to split up the table because the columns need to remain intact. I thought about using runat=server...
3
1723
by: Miguel Dias Moura | last post by:
Hello, I have 2 tables in a web page. I want to show first table and hide second when the URL parameter result=ok. And of course the oposite when result=notok. How to do this?
5
3197
by: dje | last post by:
In the OnClick event on a radioButtonList, I run a javascript to show/hide the appropriate div along with a submit button, which displays as expected. The problem is the submit no longer works on the button. If I quit using the divs, and do a postback on the radiobutton selection, showing/hiding tables instead, the button is ok and continues to work. I've tried a variety of controls instead of the button in a variety of places but it...
3
4424
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 1</td></tr> <asp:repeater id=child>
3
2608
by: Lynn | last post by:
Hello, I have a user control that contains a table, and some text fields. I would like to show or hide a particular row of this table, based on a selection the user makes on my page. Here's the situation...I have a page that has some panels that are hidden. The first panel is visible...the user selects a city, and presses submit. The next panel is made visible, and in this panel I have placed a user
0
1408
by: Mac via DotNetMonster.com | last post by:
I have a MDI parent form and the only control on it is a panel anchored to the left hand side. I have menu items on the MDI parent that show & hide this panel. Ideally I would like it to show by not pushing out the child forms, but rather be overlapping them. Alternatively I tried creating a form the same size as the panel but run into difficulty because I would like it to have a normal window state while the other child forms are...
2
3815
by: Øyvind Isaksen | last post by:
Is it possible to show/hide a usercontrol code behind? <uc1:topart id="Topart1" runat="server"></uc1:topart> This is what i want to do, but this does not work: if objDR.read me.Topart1.show 'Show usercontrol if datareader.read else me.Topart1.hide 'Hide usercontrol
1
1824
by: shapper | last post by:
Hello, I created an Asp:Repeater where I have an Asp:Panel and an Asp:Label. In each record of the repeater I want to have a small button which hides or shows the panel in that record. If possible with no postback. And it would be great to have a button like "Show" which would change to "Hide". Well, but this is not so important.
2
1251
by: arti | last post by:
In Asp.net form, I have 3 panels. I want a button on top of each panel to hide or display the panel. I am able to do it. But when there is any postback, the page loads with its design time setting- all panels are visible=false. On each panel I have a submit button and asp.net List with autoPostBack=True. So the form will postback to server. I want that if a panel was open at the time of postback, it should be open at page reload. Pl help!
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.