databinding

databinding a property to either of two dependency properties

I have two custom controls that are analogous to a node and the control that draws links between nodes. I would like to have both controls written as much in xaml as possible. The link stores both nodes as dependency properties, and I use databinding to move the line between the nodes whenever the nodes move. It would be great to be...

Should I bind directly to objects returned from a webservice?

Should I bind directly to objects returned from a webservice or should I have client-side objects that I bind to my gridcontrols? For instance if I have a service that returns object Car should I have a client side Car object that I populate with values from the webservice Car object? What is considered best-practice? In C# do I need to...

How do I bind the result of DataTable.Select() to a ListBox control?

I have the following code: ListBox.DataSource = DataSet.Tables("table_name").Select("some_criteria = match") ListBox.DisplayMember = "name" The DataTable.Select() method returns an array of System.Data.DataRow objects. No matter what I specify in the ListBox.DisplayMember property, all I see is the ListBox with the correct number of ...

When should I use # and = in ASP.NET controls?

I have been using ASP.NET for years, but I can never remember when using the # and = are appropriate. For example: <%= Grid.ClientID %> or <%# Eval("FullName")%> Can someone explain when each should be used so I can keep it straight in my mind? Is # only used in controls that support databinding? ...

How can I do Databinding in c#?

I have the following class public class Car { public Name {get; set;} } and I want to bind this programmatically to a text box. How do I do that? Shooting in the dark: ... Car car = new Car(); TextEdit editBox = new TextEdit(); editBox.DataBinding.Add("Name", car, "Car - Name"); ... I get the following error "Cannot bind to ...

Should I return a strongly typed dataset from a webservice?

Should I expose a strongly typed dataset from a webservice and bind it directly in a client? or are there more sensible ways for asmx web services? I am doing CRUD operations (Create, Read, Update, Delete). I find working with datasets to be frustrating and difficult to work with when for example when inserting into a table within it f...

C# grid binding not update

I have a grid that is binded to a collection. For some reason that I do not know, now when I do some action in the grid, the grid doesn't update. Situation : When I click a button in the grid, it increase a value that is in the same line. When I click, I can debug and see the value increment but the value doesn't change in the grid. BUT...

Is it possible to bind complex type properties to a datagrid?

How would I go about binding the following object, Car, to a gridview? public class Car { long Id {get; set;} Manufacturer Maker {get; set;} } public class Manufacturer { long Id {get; set;} String Name {get; set;} } The primitive types get bound easy but I have found no way of displaying anything for Maker. I would like...

C# serialization and event for data binding are lost

Hello, I have already posted something similar here but I would like to ask the question more general over here. Have you try to serialize an object that implement INotifyPropertyChanged and to get it back from serialization and to bind it to a DataGridView? When I do it, I have no refresh from the value that change (I need to minimize ...

winForms + DataGridView binding to a List<T>

So, every few months I write something in WinForms to remind myself why I hate it. Today is the day. I'm trying to bind a List<T> to a DataGridView control, and I'm not having any luck creating custom bindings (Ugh at all the late bound crap). I tried: gvProgramCode.DataBindings.Add(new Binding("Opcode",code,"Opcode")); It throws a...

WPF DataBinding with simple arithmatic operation?

I want to add a constant value onto an incoming bound integer. In fact I have several places where I want to bind to the same source value but add different constants. So the ideal solution would be something like this... <TextBox Canvas.Top="{Binding ElementName=mySource, Path=myInt, Constant=5}"/> <TextBox Canvas.Top="{Binding Element...

Detecting WPF Validation Errors

In WPF you can setup validation based on errors thrown in your Data Layer during Data Binding using the ExceptionValidationRule or DataErrorValidationRule. Suppose you had a bunch of controls set up this way and you had a Save button. When the user clicks the Save button, you need to make sure there are no validation errors before proc...

How do I bind an ASP.net ajax AccordionPane to an XMLDatasource?

Title says it all. I've got an angry boss that will beat me down if I waste another day on this :-P Many karma points to the ajax guru who can solve my dilemma. But more detail: I want to have an AccordionPane that grabs a bunch of links from an XML source and populate itself from said source. ...

Best way to bind a web UI against XML attributes?

I want to bind my UI against a collection of XElements and their properties on a webpage. Hypothetically, this could be for any object that represents an XML tree. I'm hoping that there might be a better way of doing this. Should I use an XPath query to get out the elements of the collection and the attribute values of each (in this c...

Bind ASP.NET DropDownList DataTextField to method?

Is there anyway to have items in an ASP.NET DropDownList have either their Text or Value bound to a method on the source rather than a property? ...

Databinding 2 WPF ComboBoxes to 1 source without being "linked"

I have a master-detail scenario where I have 1 ComboBox listing companies from an ObjectDataSourceProvider. Under that I have 2 ComboBoxes binding to the Contacts property from the current Company object. I need to be able to select a different contact in each ComboBox; however, as soon as I change selection in one list the other list ...

Do you databind your object fields to your form controls?

Or do you populate your form controls manually by a method? Is either considered a best practice? ...

How can I set the text of a WPF Hyperlink via data binding?

In WPF, I want to create a hyperlink that navigates to the details of an object, and I want the text of the hyperlink to be the name of the object. Right now, I have this: <TextBlock><Hyperlink Command="local:MyCommands.ViewDetails" CommandParameter="{Binding}">Object Name</Hyperlink></TextBlock> But I want "Object Name" to be bound t...

How do I databind a ColumnDefinition's Width or RowDefinition's Height?

Under the View-Model-ViewModel pattern for WPF, I am trying to databind the Heights and Widths of various definitions for grid controls, so I can store the values the user sets them to after using a GridSplitter. However, the normal pattern doesn't seem to work for these particular properties. Note: I'm posting this as a reference quest...

C# ResetBinding flip the DataGridView *Updated with example*

I had a problem that was partially solved. To explain it quickly : I have a grid binded to a complex object that require to be serialized. When the object is build back from the serialization, event like on the grid doesn't refresh the table display. Someone told me to rebuild the event once unserialize, it works! But the event that refr...