databinding

C# - Binding TextBox to an integer

How to bind a TextBox to an integer? For example, binding unit to textBox1. public partial class Form1 : Form { int unit; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox1.DataBindings.Add("Text", unit, "???"); } ...

How to databind to a property in a WPF Usercontrol?

Hi, I have a Usercontrol in a UserControl libracy (seperate assembly) i have in my xaml markup like this: <UserControl x:Class="CenterTextTemplate.CenterTextTemplate" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="Test" Height="Auto" Width="Auto">...

Visual Studio 2008 connection to Sql Server 2005

I have a Sql Server 2005 DB on Godaddy. I have Visual studio 2008 not express on my PC. I have tried to set the connection between VS2008 and SQLS2005 to start a project building the formns but it will not connect. I have entered the Hostname, Database name, initial file, username, and password but when I test the connect it fails. I...

wpf databinding - two way binding with a string?

I have a simple property on my view model that is of type string. I want to bind this to a textbox so that changing the textbox updates the string and changing the string updates the textbox. Do I REALLY have a write a wrapper class around the string type that implements INotifyPropertyChanged, or am I missing something incredibly simple...

How do I make sure the text of an ActionScript TextInput is updated when the Object property defining that text is updated?

Not an easy question to decipher, so let me boil it down. I'm trying to convert an MXML component to an ActionScript Class. The component consists of a Form with a TextInput, TextArea, and two buttons - Save and Cancel, and a Validator for the TextInput, and other logic to handle events that occur. This component is currently extended by...

Dynamic control type in InstantiateIn() method of ITemplate based on properties of DataItem. Is there a way?

I have a simple GridView; something like this for a regular Item or AlternatingItem row: +----+-------------+----------+ | ID | Description | Value | +====+=============+==========+ | 01 | Some text | 0.082 | +----+-------------+----------+ | 02 | Some text | Yes | +----+-------------+----------+ | 02 | Some text | 9/4/...

asp.net ajax 4.0 client templates, how to bind a select?

I am trying to create a simple ajax grid that allows me to add and remove rows and also edit some of the columns and have others columns calculated directly based on the input in the others. I thought this would be a nice oppurtunity to play with asp.net ajax 4.0 and the client templates. It works pretty ok but I can't seem to find a way...

Default Values on DetailsView Insert

When users go to a specified page, I have a DetailsView attached to a SqlDataSource and already setup in Insert mode. I'm essentially using it as a registration page for certain events. Rather than having the users type in their "UserName", I want that field to automatically populate based on that user already being logged in. Does an...

WPF binding: How to suppress validation when nothing is entered

I use WPF data binding with entities that implement IDataErrorInfo interface. In general my code looks like this: Business entity: public class Person : IDataErrorInfo { public string Name { get; set;} string IDataErrorInfo.this[string columnName] { if (columnName=="Name" && string.IsNullOrEmpty(Name)) return "Name is...

Combobox Databinding as an element inside of a Listbox in WPF

I'm having trouble with a combox databinding, this is what I'm trying to have it setup like: 1) Combo box is an item inside of a ListBox control [working] 2) Combo box's "Text" should be bound to a value from the ListBox ItemsSouce [not working] 3) The combo box will have an itemssource bound to a list that is retreived from a databas...

How might I control a checkbox in a repeater?

In my project, there is a Repeater. And in the repeater is a CheckBox. When I bind data to the Repeater, how can I control (set checked / unchecked) the CheckBoxs that are produced by the Repeater? This is what I've tried: <asp:Repeater ID="Security1" runat="server"> <ItemTemplate> <tr> <td> <asp:CheckBox ID="CheckBox1" ...

Bind silverlight combobox to the result of another combobox

I want to do something like this: <combobox x:Name="cboCustomers" ItemsSource="{Binding Path=Data.Customers}"/> <combobox x:Name="cboInvoices"ItemsSource="{cboCustomers.SelectedItem.Invoices}"/> Anyone know of a way to do something like this in Silverlight 3? I am sure there is some information about it out there, but I am having bad...

WPF combo box binding to generic list

I have a method which returns a generic list (from the db it returns a set of data to a list). I want to bind one property of that list to a combo box using ComboBox's ItemsSource="{Binding Path=ListFirstName}" property. How can i achive this? The code i tried XAML code: <ComboBox Name="cmbName" ItemsSource="{Binding Path=Exa...

WPF - data binding window title to view model property

I'm trying to bind my window title to a property in my view model, like so: Title="{Binding WindowTitle}" The property looks like this: /// <summary> /// The window title (based on profile name) /// </summary> public string WindowTitle { get { return CurrentProfileName + " - Backup"; } } The CurrentP...

Bind to ItemsControl's DataContext from inside an ItemTemplate

I have an ItemsControl whose for the ItemTemplate DataTemplate contains a Button. I want the Command on the button to bind to a Command on the DataContext of the ItemsControl, not the ItemTemplate. I think the solution has to do with using RelativeSource, but my attempts so far have failed: <ItemsControl ItemsSource="{Binding Games}"> ...

Getting the bound field name at runtime

If you bind a control in a FormView using two way binding (such as Text='<% #Bind("FieldName") %>'), how do you retrieve the field name "FieldName"? There are several things I want to do with this information; for example, I have a database table that contains a dump of all the field definitions from ERWin and I want to programmatically...

WPF Databinding to Custom Collection Objects

Public Sub New(ByVal log As Entities.LogSystem) InitializeComponent() Me.DataContext = log End Sub This is the the initializer for my custom control It passes in a single entity that has several property fields. This control is added to a parent control so that it appears in a stackpanel. Anyway I am trying to get the speci...

Trying to embed a DataItem within an asp:Image control's ImageUrl property

I have the following Image control within a repeater. I'm trying to get the username to render in between ~/profilepics/ and .jpg but I get the following rendered output /profilepics/%3C%25#DataBinder.Eval(Container.DataItem,%20%22usernameFrom%22)%20%25%3E.jpg Here is the markup <asp:Image ID="Image1" runat="server" ImageUrl='~/profil...

C# WPF PropertyChanged event always null

I have the following (abbreviated) xaml: <TextBlock Text="{Binding Path=statusMsg, UpdateSourceTrigger=PropertyChanged}"/> I have a singleton class: public class StatusMessage : INotifyPropertyChanged { private static StatusMessage instance = new StatusMessage(); private StatusMessage() { } public static StatusMessag...

How to bind Window background to a theme's Window background color?

How can I bind the default Window background color of the theme to a Window background? I've tried the following: <Window x:Class="Shell" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Shell" Height="300" Width="300" Background="...