473,379 Members | 1,533 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,379 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
5 1726
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" <mn******@gmail.comwrote in message
news:11**********************@e9g2000prf.googlegro ups.com...
Repeaters do not have DataBound event.
Correct, though they do have an OnItemDataBound method:
http://msdn2.microsoft.com/en-us/lib...nd(vs.80).aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 26 '07 #5
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 #6

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...
2
by: Steve | last post by:
I am having issues adding a new row in my repeater when my repeater's table cells reach a certain number. what i'm doing is adding a predetermined number of color cells from the database and...
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.