473,406 Members | 2,451 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,406 software developers and data experts.

Repeater in Panel

Hi Folks,

I have a situation where I have a repeater within and ASP Panel on my page.
If the repeater contains no items, then I don't need to show the panel,
however if it does then I do.

I tried the following in the page load event:

// Check to see if we have any new messages
if(repMessages.Items.Count == 0)
{
pnlMessages.Visible = false;
}
if(repMessages.Items.Count 0 )
{
pnlMessages.Visible = true;
}
However that didn't work, so I figured that the data must be bound after
the page load event fires.So I then tried:

protected void repMessages_ItemDataBound(object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
pnlMessages.Visible = true;
}

Thinking that if an item is being databound, then the Items.Count
property of the repeater must be 0. However that didn't work either.

So my question is, How can I show and hide a panel which contains a
repeater based on the content (or lack of) of the repeater itself?

Kind Regards
Mick
Aug 26 '07 #1
4 1913
This is the C# language newsgroup. You want to post this in the asp.net
group, as it is really not so much a language question as it is an ASP.NET
framework one.
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Mick Walker" wrote:
Hi Folks,

I have a situation where I have a repeater within and ASP Panel on my page.
If the repeater contains no items, then I don't need to show the panel,
however if it does then I do.

I tried the following in the page load event:

// Check to see if we have any new messages
if(repMessages.Items.Count == 0)
{
pnlMessages.Visible = false;
}
if(repMessages.Items.Count 0 )
{
pnlMessages.Visible = true;
}
However that didn't work, so I figured that the data must be bound after
the page load event fires.So I then tried:

protected void repMessages_ItemDataBound(object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
pnlMessages.Visible = true;
}

Thinking that if an item is being databound, then the Items.Count
property of the repeater must be 0. However that didn't work either.

So my question is, How can I show and hide a panel which contains a
repeater based on the content (or lack of) of the repeater itself?

Kind Regards
Mick
Aug 26 '07 #2
Mick Walker wrote:
Hi Folks,

I have a situation where I have a repeater within and ASP Panel on my
page. If the repeater contains no items, then I don't need to show
the panel, however if it does then I do.

I tried the following in the page load event:

// Check to see if we have any new messages
if(repMessages.Items.Count == 0)
{
pnlMessages.Visible = false;
}
if(repMessages.Items.Count 0 )
{
pnlMessages.Visible = true;
}
However that didn't work, so I figured that the data must be bound
after the page load event fires.So I then tried:

protected void repMessages_ItemDataBound(object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
pnlMessages.Visible = true;
}

Thinking that if an item is being databound, then the Items.Count
property of the repeater must be 0. However that didn't work either.

So my question is, How can I show and hide a panel which contains a
repeater based on the content (or lack of) of the repeater itself?

Kind Regards
Mick
Just put your code in Repeater1_DataBound instead of Page_Load.
Don't use ItemDataBound, because it will be executed for every item.
Once (after the databinding) is enough.

--

Riki
Aug 26 '07 #3
Repeaters do not have DataBound event.

Aug 26 '07 #4
Muhammad Naveed Yaseen wrote:
Repeaters do not have DataBound event.
My mistake.

If you use declarative databinding with a SqlDataSourceControl or
AccessDataSourceControl, you may use the OnSelected event on that control.

--

Riki
Aug 27 '07 #5

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

Similar topics

2
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted...
0
by: Fraggle | last post by:
I am using PlaceHolders in a Repeater to generate a multi choice survey. I need a way of testing to see what the placeholder has been turned into at runtime, and reading out the data. The admin...
1
by: Fraggle | last post by:
I have a repeater with controls added at run time. the <template> also contains a <asp:textbox that is made visible on some repeater elements. when I come to read the text info out it has...
1
by: laurence chang | last post by:
I'm using a repeater to display a query result from sql table. I bind the repeater to a sqldatareader. I set repeater's template to a table. I can display query result very well, but some time the...
1
by: Charlie | last post by:
Hi: I'm laying out a hieraracical report by nesting repeater controls. I'm using panels to expand/collapse detail sections. To access a panel in a nested repeater, I use the following code. ...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: =?Utf-8?B?S29uc3RhbnRpbg==?= | last post by:
I have a need to have a repeater inside update panel control which should update dynamically when "Update" button is clicked. I have repeater inside update panel control which takes custom...
5
by: Mick Walker | last post by:
Hi Folks, I have a situation where I have a repeater within and ASP Panel on my page. If the repeater contains no items, then I don't need to show the panel, however if it does then I do. I...
1
by: Andy B | last post by:
I have a repeater control with an ItemTemplate inside of it. In the ItemTemplate, I have a div with a link that calls a javascript function to make an asp:Panel control visible or invisible. I need...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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.