databinding

Push data back from control to source without Validating event

I have TextBox controls on a WinForm bound to a BindingSource. If I set CausesValidation = false on these controls it doesn't update data source on tableAdapter.Update() method. I know that Control.Validating event does this saving but how can I update source if CausesValidation is disabled? ...

Logic in get part of property. Good practice?

When databinding my xaml to some data I often use the "get" part of a property to do some logic. Like giving to sum of totals of a list or a check if something is positive. For example: public List<SomeClass> ListOfSomeClass{get;set;} public double SumOfSomeClass { get { return ListOfSomeClass.Sum(s => s.Totals); } } public...

Expression Blend does not list my application's objects in CLR objects

I'm following a video tutorial on data binding with Visual Studio / Expression Blend. In the tutorial the application's custom objects are listed when the presenter clicks on the "+CLR Object" button, but in when I do it, my application's objects are not listed. What do I need to do to get my application's objects to be listed here? ...

C# asp.net gridview bind dropdownlist to List<keyvaluePair<int, string>>

Hi all, OK,... so I have a number of tables in my DB that hold references to an key value pair: types of phone numbers: 1 - Home 2 - Work 3 - Mobile 4 - Fax etc So I have a table for the types and when they are used in other tables they reference the int value as a foreign key. When I have been pulling them out I have been storing...

Bind to a method in WPF?

How do you bind to an objects method in this scenario in WPF? public class RootObject { public string Name { get; } public ObservableCollection<ChildObject> GetChildren() {...} } public class ChildObject { public string Name { get; } } XAML: <TreeView ItemsSource="some list of RootObjects"> <TreeView.Resources> ...

Binding in a WPF data grid text column

I'm trying to build a data grid where one of the columns is a font name displayed in that font. Previously, I was working with a list box where I had defined the following template: <TextBlock Text="{Binding Path=Name}" FontFamily="{Binding Path=Name}"/> This worked just fine. So, I tweaked the data structure (Name became Font.Name) a...

Two way data binding in a GridView

We have an app that uses simple one way binding with a GridView to display some data. Well, now we need to allow the user to change some of that data, so I've been trying to get two way data binding to work in the GridView. So far everything displays correctly, but editing cells in the GridView seems to do nothing at all. What am I messi...

Binding Textboxes

I have been binding textboxes in a winform with C# to a dataset. Whenever the data doesn't validate with what the database except it silently forces the focus to remain on the textbox. How can I catch the validation error and tell the user about it (and free the focus)? The BindingSource event OnDataError isn't fired. ...

How to properly bind a ListBoxItem in WPF ?

I have a listbox and I want to iterate over a collection of Bars in my Foo-object. <ListBox DataContext="{Binding Path=Foo.Bars}" > <ListBox.Items> <ListBoxItem> <ContentControl DataContext="{Binding Path=.}" /> </ListBoxItem> </ListBox.Items> </ListBox> This is the datatemplate I want to use. <Dat...

asp:repeater - headers at section change

Hi, is there any way to bring up a subheader row at changes in a field in an databound asp:repeater control e.g. Instead of country | colour | number uk | red | 3 uk | green | 3 france | red 3 Do this: ==UK== colour | number red | 3 green 3 ==FRANCE== colour | number red | 3 Many thanks for any help. ...

How to get design surface rendering and design time datasource selection with an asp.net user control

If I create a user control (EDIT:not a web control/server control) it's pretty trivial to get databinding. I just add a datasourceID property. In code behind (vb) Partial Public Class BandedControl Inherits UserControl Public Property DataSourceID() As String Get Return MyGridView.DataSourceID End ...

Silverlight ItemsControl. Can you remove the panel completely via templating?

I have a DataTamplate for my ItemsControl that merely contains an Image with some other meta data. What I am trying to do is bind to the ItemsControl and have the Images be displayed with the Convas.Left and Canvas.Top that is bound via the data I give. I have been trying my best to remove any Panels from the control via the ItemsPanel...

How do I catch and present conversion errors during databinding?

WinForms has great databinding support, and the ErrorProvider makes it quiet easy to display business object errors. However, the conversion errors seems to be swallowed. If I type 'aaa' into a TextBox databound to an integer property, I get nothing from the ErrorProvider. So in this case my UI tells me everything is fine, when 'aaa' is...

Bind to animated property (WPF)

Hi, Does anybody knows, if there is a way to use a property that is animated as source for a binding? As far as I found out, is that an animation doesn't "really" set the value on the property, and therefore doesn't fire the changed events, which is needed to trigger the binding. tia Martin ...

How to put logic into my DataTemplate, e.g. handle a blank address line?

I'm starting to understand XAML data binding and using the DataTemplate and it's pretty nice. What is the best way to take the next step and put logic into the code below, e.g. look to see if there is anything in "Address2" and if so display it, or format foreign addresses differently, etc.? <Window.Resources> <DataTemplate x:Key...

How to use HtmlEncode with TemplateFields, Data Binding, and a GridView

I have a GridView bound to an ObjectDataSource. I've got it supporting editing as well, which works just fine. However, I'd like to safely HtmlEncode text that is displayed as we do allow special characters in certain fields. This is a cinch to do with standard BoundFields, as I just set HtmlEncode to true. But in order to setup vali...

Bound Textbox to a currency, how to get the double?

I have a textbox bound to a currency data field. So it adds '$' to the start of the text or ($xx.xx) if it's negative. How do I get just the plain double (xx.xx) from the textbox instead of everything ($xx.xx)? ...

TinyMCE and ASP.NET Data Binding Question

I have a data-source connected to a stored proc that will return the one record that applies to a specific page, and for another similar situation (populating heading information), I wrapped a repeater around the headings html, and used <%$ Eval() %> binding expressions to get the data into the headings. However, I now have another issue...

WPF Binding relational ComboBox's from L2S with filtering on all of them.

Hi, in a WPF project with Linq to SQL, if you use the O/R - designer to create a simple structure with 3 that are all tied with forgin key relataions like so: Customer <-- Orders <-- Items, and say i want a simpe window with 3 syncronized comboboxes when you select a customer you see only his orders and when you select an Order you see...

Spring - binding to an object rather than a String or primitive

Hello, Let's say I have the following command object: class BreakfastSelectCommand{ List<Breakfast> possibleBreakfasts; Breakfast selectedBreakfast; } How can I have spring populate "selectedBreakfast" with a breakfast from the list? I was figuring I'd do something like this in my jsp: <form:radiobuttons items="${possibleBreakfas...