Formatting DataBinder.Eval data

There is an optional overload for DataBinder.Eval to supply formatting: <%# DataBinder.Eval(Container.DataItem, “expression”[, “format”]) %> The format parameter is a String value, using the value placeholder replacement syntax (called composite formatting) like this: <asp:Label id=”lblNewsDate” runat=”server” Text=”<%# DataBinder.Eval(Container.DataItem, “publishedDate”, “{0:dddd d MMMM}”) %>”</label>

How do I use Format-Table without truncation of values?

The $FormatEnumerationLimit preference variable doesn’t apply here, because its purpose is to determine how many elements of a collection-valued property to display (e.g, $FormatEnumerationLimit = 2; [pscustomobject] @{ prop = 1, 2, 3 } prints (at most) 2 elements from .prop‘s value and hints at the existence of more with …; e.g., {1, 2…}). Instead, … Read more

How can you use a variable name inside a Python format specifier

Yes, but you have to pass them in as arguments to format, and then refer to them wrapped in {} like you would the argument name itself: print(‘\n{:^{display_width}}’.format(‘some text here’, display_width=display_width)) Or shorter but a little less explicit: print(‘\n{:^{}}’.format(‘some text here’, display_width)) Since this question was originally posted, Python 3.6 has added f-strings, which allow … Read more

What is the WPF XAML Data Binding equivalent of String.Format?

You can use MultiBinding + StringFormat (requires WPF 3.5 SP1): <TextBox.Text> <MultiBinding StringFormat=”{}{1:#0}% up, {2:#0}% down”> <Binding Path=”PercentageOne” /> <Binding Path=”PercentageTwo”/> </MultiBinding> </TextBox.Text> Regarding Run.Text – you can’t bind to it but there are some workarounds: http://fortes.com/2007/03/20/bindablerun/ http://paulstovell.net/blog/index.php/attached-bindablerun/