databinding

Binding DynamicObject to a DataGrid with automatic column generation?

I'm still experimenting with DynamicObjects. Now I need some information: I'm trying to bind an object inheriting from DynamicObject to a WPF DataGrid (not Silverlight). How do I get the DataGrid to automatically create its columns from the available public properties of the object that are typically generated at runtime? Is that possi...

Winforms Bind Enum to Radio Buttons

If I have three radio buttons, what is the best way to bind them to an enum which has the same choices? e.g. [] Choice 1 [] Choice 2 [] Choice 3 public enum MyChoices { Choice1, Choice2, Choice3 } ...

Why does a simple ApplicationSetting PropertyBinding for a Form does not work in C#?

My question involves this simple walkthrough shown in the article Preserve Size and Location of Windows Forms – Part I by Dennis Wallentin. This approach works 100% fine when using VB.NET. When using the same steps in C#, however, the settings within the Settings tab of the application's properties looks correct, and the app.config fil...

How to set binding in xaml to my own variable

Hello. I have an object in the code: public class UserLogin { bool _IsUserLogin = false; public bool IsUserLogin { get { return _IsUserLogin; } set { _IsUserLogin = value; } } public UserLogin() { _IsUserLogin = false; } } .... ...

Databinding to ObservableCollection in a different UserControl - how to preserve current selections?

Scope of question expanded on 2010-03-25 I ended up figuring out my problem, but here's a new problem that came up as a result of solving the original question, because I want to be able to award the bounty to someone!!! Once I figured out my problem, I soon found out that when the ObservableCollection updates, the databound ComboBox h...

How to setup a WPF datatemplate in code for a treeview?

struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Drink ( string name, int popularity ) : this ( ) { this.Name = name; this.Popularity = popularity; } } List<Drink> coldDrinks = new List<Drink> ( ){ new Drink ( "Water", 1 ), new...

Queryable and BindingSource item add .net

Hello! I wrote my own simple Queryable provider which retrieves data from a database. Now I need to bind this data to a BindingSource and when the new item is added to BindingSource some event or method must be called for handling the add operation. I have tried to implement IBingingList on a List class which is returned when the quer...

How to determine if an item is the last one in a WPF ItemTemplate?

Hi everyone, I have some XAML <ItemsControl Name="mItemsControl"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text="{Binding Mode=OneWay}" KeyUp="TextBox_KeyUp"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> that's bound to a simple ObservableCollection private ObservableCo...

How do I initialize the controls in an InsertItemTemplate?

I have - for instance - an asp:FormView which supports Read, Insert, Update, Delete and is bound to a DataSource: <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" > <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("MyText") %>' /> </ItemTemplate> <EditItemTemplate> ...

How to check if SqlDataSource1 select method returns 0 nodes ?

how can I check if my SqlDataSource1 select method returns 0 count of nodes (rows) after : SqlDataSource1.DataBind(); ...

WPF Binding with RelativeSource of Window Requires "DataContext" in Path?

The following code works, but I'm curious as to why I need the Path to be prefixed with "DataContext"? In most other cases, the path used is relative to DataContext. Is it because I am using a RelativeSource? Because the source is at the root level (Window)? <Style TargetType="TextBox"> <Setter Property="IsRea...

client side AJAX 4 Data binding Syntax for child tables in Linq2SQL returned from WCF, help !

hi, i am really lost at this, i am able to get the jason result and here is it from firebug console {"d":[{"__type":"Table1:#","id":1,"name":"asd","Table2s":[{"__type":"Table2:#","id":2,"family":"dfdfd","fid":1}]},{"__type":"Table1:#","id":2,"name":"wewe","Table2s":[{"__type":"Table2:#","id":1,"family":"fff","fid":2}]}]} now my quest...

Binding Dictionary<T> to a WPF ListBox

Given a dictionary of <string, Drink>, how would you bind the dictionary.Values to a WPF ListBox, so that the items use the .Name property? struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Drink ( string name, int popularity ) : this ( ) { this.Na...

Binding, Prefixes and generated HTML

MVC newbie question re binders. Supposing I have two strongly typed partial actions that happen to have a model attributes with the same name, and are rendered in the same containing page i.e.: Class Friend {string Name {get; set ;} DateTime DOB {get; set ;}} Class Foe {string Name {get; set ;} string ReasonForDislike {get; set ;}} Bo...

DataContext, DataBinding and Element Binding in Silverlight

I'm having one hell of a time trying to get my databinding to work correctly. I have reason to believe that what I'm trying to accomplish can't be done, but we'll see what answers I get. I've got a UserControl. This UserControl contains nothing more than a button. Now within the code behind, I've got a property name IsBookmarked. When I...

Conditional Markup in aspx

Hi... I have a ListView. If I want to base the html markup on a condition in respects to the databound item, what would be the best way to do that? What I mean is, is there any other way then putting <% %> if/else blocks directly in the markup? I'm aware that a really ugly way of doing it, is putting html markup in the database field,...

Is it possible to bind data asynchronously between two dropdownlists in a view?

I'd like to achieve the following effect using ASP.NET MVC and JQuery. I've got a drop down list displaying a list of Countries. I want to make it so that when I change the value of the country, a new drop down list appears below it, showing a list of companies whose country of origin is the particular selected company. The thing is th...

Very basic Silverlight binding question

I have a custom UserControl called (for instance) MyPanel, and I want to use it in another XAML file. I would like to set a property of MyPanel, such as "Title" in the XAML file into which MyPanel is placed, as follows: <UserControl x:Name="ContainerControl"> <local:MyPanel Title="Whatever I Want" /> </UserControl> I would like f...

Odd behaviour binding persistent property, property setter throws unrelated exception

I've got a person object with properties: public Person { private string name; public string Name { get { return this.name; } set { SetPropertyValue<string>("Name", ref this.name, value); } } [Association("Person-City"), Persistent("BillingCityID")] public cityType BillingCity { get; set; } } ...

asp.net databinding using jQuery

Hi! I'm developing an asp.net application and need to bind view data to model using jQuery. I have two UnorderedLists's and using drag&drop between them with jQuery's sortable(), ulSource and ulDestination. In code behind, there are two model class as Destination and Source. using standart asp.net binding its sth like that: <asp:Bulle...