Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Controls / October 2006

Tip: Looking for answers? Try searching our database.

ButtonField and Eval

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 25 Oct 2006 17:51 GMT
Hi;

In ButtonField for the text I want to do:
Text='<%# Eval("Title", Resources.Windward.ReportList_Confirm) %>'

Where the resource has a {0} in it for the Title property. This doesn't work
- says I need a DataBinding event. Is there a way to do this?

And why do none of the DataControlField derived classes have this?

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

alvinzc@gmail.com - 26 Oct 2006 03:23 GMT
Hi, you can't do in the ButtonField control (unless you do it on normal
Button server control in the TemplateField). ButtonField exposes
DataTextField and DataTextFormatString properties, which you can be
used for that purpose by assigning the DataTextFormatString property
programmatically with the value in
Resources.Windward.ReportList_Confirm in RowDataBound event.

Hope this helps...

Regards,
Alvin Chooi
Microsoft ASP.NET Enthusiast
http://alvinzc.blogspot.com
David Thielen - 26 Oct 2006 03:34 GMT
I need the Eval for another property I am adding - OnClientClick. So the
problem remains.

My big question is why do the DataControlField derived classes not have a
databinding event? It seems that it would be natural for them to have it.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hi, you can't do in the ButtonField control (unless you do it on normal
> Button server control in the TemplateField). ButtonField exposes
[quoted text clipped - 9 lines]
> Microsoft ASP.NET Enthusiast
> http://alvinzc.blogspot.com
David Thielen - 26 Oct 2006 03:53 GMT
I need to explain this better - I have created a control that inherits from
ButtonField. In it I am creating a property OnClientClick (for onclick
functions). The onclick function needs a property from the row for the text
in it.

I can implement it as either the pair of properties, the format string and
the fields used. Or I can add databinding to the control. But my question is:

1) Why is there no way to get a property from the row data in a
DataControlField? I would think you would need that a lot.
2) Is there a strong reason to not add databinding to my inherited control?
I like that approach because it's one property instead of two.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> I need the Eval for another property I am adding - OnClientClick. So the
> problem remains.
[quoted text clipped - 15 lines]
> > Microsoft ASP.NET Enthusiast
> > http://alvinzc.blogspot.com
Walter Wang [MSFT] - 26 Oct 2006 07:18 GMT
Hi David,

Would you please tell me more about your custom ButtonField control? Such
as why you want to inherit from ButtonField, what's the purpose of this
field?

A ButtonField represents a field that is displayed as a button in a
data-bound control. It's not inheriting from Control or WebControl, and it
doesn't have the DataBinding event and the BindingContainer property which
are required for Data Binding expression to work on it.

IMHO, the ButtonField is only used where you need to render a field as
button or link, other than that purpose, it's recommended to use
TemplateField which you have full control.

Anyway, I think we might discuss it further after you described more about
the purpose of the customized ButtonField control. Thanks.

Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen - 26 Oct 2006 16:15 GMT
Hi;

I'm using it as an Image button and then addint the onmouseover, etc to have
3 bitmap images. I like inheriting from ButtonField because then adding that
item as a column in a GridView is a single <aspMy:MyButtonField...> node
rather then <asp:Template><ItemTemplate><asp:LinkButton> which makes it more
complex.

I can do this either way. I think my real questions are:
1) What are the tradeoffs of using a DataControlField vs a Template node for
each column in a GridView? I know they both work but they seem to be designed
differently and that leaves the question of what each was meant for.
2) Why is there no databinding in a DataControlField? Again, that seems to
me to be a natural. So if I have my own derived DataControlField and need an
OnClientClick property - should I have a OnClientClickFormat and
OnClientClickData or just an OnClientClick plus databinding?

I know how to implement this either way. My question is what is the "right"
way to do so. I'm worried that I don't understand why there are these two
approaches to adding column controls and when each makes more sense.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hi David,
>
[quoted text clipped - 39 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 27 Oct 2006 04:26 GMT
Hi David,

You can find more detailed information on the difference between
DataControlField and TemplateField, also with a custom data control field
example on how to get the bound data:

#Custom Data Control Fields
http://msdn.microsoft.com/msdnmag/issues/06/01/CuttingEdge/

I think your requirement can be done using a customized DataControlField.
Please have a look at the above example and see if it helps.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
alvinzc@gmail.com - 26 Oct 2006 04:07 GMT
It is because the ButtonField's Text property does not have
BindableAttribute set to true but normal Button server controls like
Button, ImageButton do.

Hope this helps...

Regards,
Alvin Chooi
Microsoft ASP.NET Enthusiast
http://alvinzc.blogspot.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.