databinding

How can I tell when the last row of a ListView data source is being bound?

I have a nested ListView control and within the ItemTemplate I need to make a call to a method in the code-behind file in order to apply a different CSS class to the final row in the rendered table. I am calling the method as follows... <td class="<%# GetClass(Container) %>"> Container gives me the ListViewDataItem that is being boun...

How to force binding evaluation every time a ContextMenu is opened ?

I have a ContextMenu with a MenuItem in it: <Grid> <Button Content="{Binding Test}"> <Button.ContextMenu> <ContextMenu> <StackPanel> <MenuItem Header="{Binding Test}"/> </StackPanel> </ContextMenu> </Button.ContextMenu> </Button> </Grid> ...

WPF, two-way binding to a hash table doesn't update the source object

Hi, I am wondering if anyone can help, I am able to bind to a hash table and display values correctly, yet the two-way binding I have specified doesn't update the object when I make changes. <DataTemplate x:Key="ResponseItemTemplate"> <StackPanel Orientation="Horizontal" > <TextBox Width="200" Text="{Binding Path=...

How do I get a WPF listview to format a byte array as a comma-delimited string?

I'm trying to bind some data to a WPF listview. One of the properties of my data type is of type byte[] and I'd like it to be shown as a comma-delimited string, so for example { 12, 54 } would be shown as 12, 54 rather than as Byte[] Array. I think I want to make a custom DataTemplate but I'm not sure. Is that the best way? If so, ho...

How to refresh a GridView/LINQ data source from textbox onchange event

I've been having troubles getting my textbox to refresh a GridView from the onchange event. The GridView is linked up to a LINQ data source and the LINQ data source has a Where Parameter UserId that it gets from the textbox... Here's the code: <asp:Label ID="label_UserId" runat="server" Text="Search by User Id: "></asp:Label> <...

Binding error in linq to sql

hi how do I solve this problem? Exception : This causes two bindings in the collection to bind to the same property. Parameter name: binding Code : var q = Movie_List.Actors.Where(a => a.Actor_Name == Snametxt.Text); Acttxt.DataBindings.Add("Text", q, "Actor_Name"); ...

Strongly typed databinding in WPF/Silverlight/XAML?

One of my biggest pet peeves with how databinding works with XAML is that there's no option to strongly type your databindings. In other words, in C#, if you want to access a property on an object that doesn't exist, you won't get any help from Intellisense, and if you insist on ignoring Intellisense, the compiler will gripe at you and ...

ASP.NET Retrieving GirdViewRow.DataItem on arbitrary post back

Hi there, Is there any way to get a GridViewRow's DataItem property in the handler for an arbitrary post-back?? All DataItems have values during the RowDataBound event, but are null in Button_Click for example, im assuming because the Grid is in the process of being databaound in the first event. I do some formatting on the fly in Row...

How to pass reference of an control to another control in XAML

Hi, Im having requirement of passing reference of control to another custom control . Like I created custom control which contains dependency property associateDatagridProperty public static readonly DependencyProperty AssociatedDataGridProperty = DependencyProperty.Register( "AssociatedDatagrid", ...

WPF binding not working properly with properties of int type

Hi, I am having a property of int type in my view model which is bound to a text box. Everything works properly, two way binding works fine except in one case - If i clear the value of text box, property setter doesn't gets called and although value is cleared in text box, property still holds the previous value. has anyone faced simi...

Is it possible to bind a WPF control to multiple data contexts?

Hi! I've written an UserControl whose DataContext contains a collection and an bool property. The collection is being displayed (and editited) within a data grid, which has custrom column templates. The DataContext of a control in a column is of course an item of the collection of the UserControl's DataContext. However I need to bind on...

What's wrong with beans binding

I am starting work on a project that has some code written in BeansBinding. It seems to work, but I found this scary post: http://weblogs.java.net/blog/fabriziogiudici/archive/2009/03/lets_fork_beans.html It appears that development on BeansBinding has stopped. Why wouldn't this ambitious developer just pick up where the other develop...

WPF databinding to composite class patterns?

I am trying out WPF for the first time and I am struggling with how to bind controls to a class that is built up using composition of other objects. For example, If I have class Comp that is built up of two separate classes (note various elements left out for clarity): class One { int _first; int _second; } class Two { string...

Change value of databound control within Repeaters in C#

Hey SO, I have a nested repeater control that displays a list of data, in my case it is an FAQ list. here is the design portion: <asp:Repeater ID="lists" runat="server"> <ItemTemplate> <h2 class="sf_listTitle"><asp:Literal ID="listTitle" runat="server"></asp:Literal></h2> <p class="sf_controlListItems"> ...

If DataBind() is called inside Page_Load(), then SqlDataSource doesn’t perform updates

If I bind GridView (via DataSourceID attribute) to SqlDataSource and set SelectCommand and UpdateCommand attributes, then everything works perfectly. But I’ve noticed that if I, for whatever reason, also manually call DataBind() inside Page_Load(), then SqlDataSource doesn’t perform any updates, even though SqlDataSource.Updating and S...

Databinding a List to a usercontrol in an Item Template in codebehind

I have a DataList like below: <asp:DataList runat="server" ID="myDataList"> <ItemTemplate> <uc:MyControl ID="id1" runat="server" PublicProperty='<%# Container.DataItem %>' /> </ItemTemplate> </asp:DataList> The Item Template is simply a registered usercontrol, MyControl. The DataSource for the DataList is a List<List<T>> a...

Confused about databinding in ASP.NET

Lets say I have an object class Person { public string Name { get; set; } public int Age { get; set; } } And that object is retrieved from a Factory (ie Can't use SQLDataSource or anything like that) Person person = PersonFactory.GetPerson(); How can I two-way DataBind the two properties to Textboxes on a web form? I looke...

Can't get Formview to update, what am I doing wrong?

I'm messing around with a Formview in asp.net. I know that the UpdateCommand needs to be specified so that the Formview knows what SQL query to run. Do I need to write an event in addition to the code the Formview sets up in order to properly fire off the SQL query? In addition, I don't get a SQL error or anything, it just does not b...

How do I build control that determines property value based on bound DataSource?

Hi, I have a database of people and shirts. Each person has specific shirts that he likes to wear. For this, I have three tables. Person, Shirt, and PersonShirt. PersonShirt consists of a list of rows with a PersonId and ShirtId. For UI, I'm using a CheckedComboBox. This is a combo box of checked items. For a specific person, the combo b...

What is the best way in WPF/Silverlight for simple dropdown that displays appropriate data?

Below is a simple WPF application which displays Customers with the most orders which is collected from the database via LINQ-to-SQL in the code-behind. What is the best way to extend this WPF application so that the user can select from a dropdown, e.g.: Customers with the most orders Customers with the least orders Customers by city...