|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ButtonField and EvalHi;
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? -- 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 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 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. -- Show quoteHide quotethanks - dave david_at_windward_dot_net http://www.windwardreports.com Cubicle Wars - http://www.windwardreports.com/film.htm "alvi***@gmail.com" wrote: > 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 > > 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. -- Show quoteHide quotethanks - dave david_at_windward_dot_net http://www.windwardreports.com Cubicle Wars - http://www.windwardreports.com/film.htm "David Thielen" wrote: > 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. > > -- > thanks - dave > david_at_windward_dot_net > http://www.windwardreports.com > > Cubicle Wars - http://www.windwardreports.com/film.htm > > > > > "alvi***@gmail.com" wrote: > > > 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 > > > > 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 (waw***@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. 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. -- Show quoteHide quotethanks - dave david_at_windward_dot_net http://www.windwardreports.com Cubicle Wars - http://www.windwardreports.com/film.htm "Walter Wang [MSFT]" wrote: > 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 (waw***@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. > > 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 (waw***@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. 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
asp.net 2.0 gridview controls - bound or unbound?
3 step wizard - ignore last step Can't duplicate ID in subclassed GridView Gridview sorting event - Gridview Datasource always Null .. why??? WebParts & Highend Portals Javascript and asp.net - TextBox backcolor not changing... way to make 2 GridViews line up CustomValidator inside Repeater is ignored javascript and navigateurl a bug in BaseValidator.RegisterValidatorCommonScript() implementat |
|||||||||||||||||||||||