Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2009, 05:30 PM
Registered User
 
Join Date: Oct 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Questions regarding PollBox control.

I have questions regarding PollBox control.

In PollBox.ascx.cs:

I am not sure I understood why there is a need to override DataBind()

Code:
public override void DataBind()
{
       base.DataBind();
       // with the PollID set, do the actual binding
       DoBinding();
 }
We can Set PollID by getting it from appropriate store procedure (via BLL).

So what I need to understand:
1)Why we need to override DataBind()
2)What is the problem with PollID
 
Old October 29th, 2009, 05:14 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

You need to override DataBind() because the poll that is actually displayed is based on what the PollID is.

In some cases, the control is used like this:

Code:
<mb:PollBox id="PollBox1" runat="server" PollID='<%# Eval("ID") %>'
ShowHeader="False" ShowQuestion="False" ShowArchiveLink="False" />
In other cases, it is used like this:

Code:
<mb:PollBox id="PollBox1" runat="server"
ShowHeader="False" ShowQuestion="False" ShowArchiveLink="False" />
In the case where the PollID is specified declaratively, we need to show the specified Poll. In cases where no PollID is specified, we need to show the Current Poll.

In order to do that, you need to determine what the PollID is, and you do that by calling base.DataBind(); Then, you need to determine which poll to show based on the evaluated ID, which is done in the call to DoBinding().
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old October 29th, 2009, 06:28 PM
Registered User
 
Join Date: Oct 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I've tried those 2 controls (the one with specified PollID and the other one) none of them triggers DataBind() method.

Anyway, If i put
Code:
<mb:PollBox id="PollBox1" runat="server" PollID='<%# Eval("ID") %>'
ShowHeader="False" ShowQuestion="False" ShowArchiveLink="False" />
im master page, i won't get any value for PollID='<%# Eval("ID") %>' the page doesn't have "ID" bounded data.

Last edited by daniel_d; October 29th, 2009 at 06:35 PM..
 
Old October 29th, 2009, 07:01 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by daniel_d View Post
im master page, i won't get any value for PollID='<%# Eval("ID") %>' the page doesn't have "ID" bounded data.
Of course not. The Eval method is meant to work in the context of a data bound control.

If you are NOT using it as part of a databound control. then you need to either not specify PollID at all, in which case it will show the "Current" poll:

Code:
<mb:PollBox id="PollBox1" runat="server" ShowHeader="False" ShowQuestion="False" ShowArchiveLink="False" />
... or, you have to specify a hard-coded ID, if you want to show a particular poll:

Code:
<mb:PollBox id="PollBox1" runat="server" ShowHeader="False" PollID= "24" ShowQuestion="False" ShowArchiveLink="False" />
In either of these cases, the Databind method will not be triggered, because there is no databound control which calls it.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
The Following User Says Thank You to Lee Dumond For This Useful Post:
daniel_d (October 29th, 2009)
 
Old October 29th, 2009, 07:23 PM
Registered User
 
Join Date: Oct 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

great, this answers my question!
Thanks




Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Interview Questions, C# Interview Questions, dotnetuncle .NET Framework 2.0 4 June 22nd, 2019 07:03 AM
questions ks1102 Excel VBA 1 April 9th, 2009 11:13 AM
Master Page Control/Web.Sitemap Questions kwilliams ASP.NET 2.0 Professional 2 January 14th, 2007 09:32 PM
C# questions zhenliu C# 1 April 15th, 2004 09:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.