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 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
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
Repeaters do not have DataBound event.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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. ...
|
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...
|
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...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |