datacontext

wpf datagridview combobox colmun ItemsSource binding problem

Hi, I cant seem to bind the datagridview's comboBoxColumn's ItemsSource Property the way I want. My Class hierachy used for this application is like this, I have a class called "PrescriptionViewModel" Inside it I have set the userControls (the view) data context to an object of "PrescriptionPresenter". Inside the "PrescriptionPresente...

MVC2.NET pass object from viewmodel to view and acces it.

Hi, When working with Viewmodels from linq to sql I have an architectural problem. When you have an object from your db (let's say "person"), and you load it in your viewmodel. After this in your view, when you try to acces referenced classes (let's say a person has children object which is a different table in db, and a different data...

How to change data context and re-render single RadGridRow

After rendering full grid I need to change data context of selected Row since initially "simple" objects are filled as data source and when single item is selected (looking at RowDetailsVisibilityChanged event), then I want to change DataContext to complex object, that shows much more info in details than in collapsed row. Using GridVie...

Lose databinding possibilities with UoW pattern in Linq to Sql

I'm currently working on my first Linq-to-Sql app. I've implemented the data-access methods with a short dataContext lifetime like this: public IProduct GetByCode(string code) { using (var db = new dataContext()) { return db.Products.SingleOrDefault(e => e.Code == code); } } I'm wondering how to get change notif...

How to set d:DesignInstance to a generic type ?

Hello all, An easy one ;-) I declared: xmlns:om="clr-namespace:System.Collections.ObjectModel;assembly=System" I try to set a generaic as the DataType: <DataGrid d:DataContext="{ d:DesignInstance Type=om:ObservableCollection&lt;System:Int32&gt;}" /> But I'm receiving an error: "Invalid format for a type". Anybody ha...

Merge an Object that wen outside the datacontext

Hi, I have the following question: It is easy to insert an oBject in database with a form. Just create an object link it to the fields in your from. Post back to controller, create a new datacontext and do datacontext.InsertOnSubmit(object) . public static void AddPage(string lang, Page page) { ...

Cannot Attach or Add an entity that is not new??

I have read the various posts regarding this error message and have typically avoided this problem in the past, but still haven't been able to figure this one, why am I getting this error: System.NotSupportedException: An attempt has been made to Attach or Add an entity that is not new, perhaps having been loaded from another DataContex...

Iterating tables in a context and the properties of those tables

I'm iterating the tables of a context and then the properties of those tables to eager load all columns in a context. I received some help via another question, but I don't seem to be able to figure out how to iterate the column properties of the actual table. Final working code: public static void DisableLazyLoading(this DataContext...

Silverlight4 Element Binding Weirdness.

I'm a bit of a .net newbie and I've been working on my first big silverlight project. So pardon the lack of lingo and the length of the question. But my problem is as follows. The project is being built according to the MVVM pattern ( in this case I'm using LightMVVM ). Most of the views contain ListBoxes. These listboxes need to ha...

ioc - castle windsor in asp.net mvc 2 + data context + connection string

I'm using castle windsor in asp.net mvc 2, with a separate project for the domain model which contains datacontext (dbml), I've deleted the app.config in the domainmodel project getting the following error: Can't create component 'DomainModel.Concrete.ArticleRepository' as it has dependencies to be satisfied. DomainModel.Concrete.Arti...

ASP.NET MVC2 RenderAction makes parent loose ViewModel context

I'm my Project Browser page I have 2 sub-elements that warrant their own controller (and not simply a user-control) - Upload and FileBrowser, and so I've added them using Html.RenderAction(Action, Controller, param). The problem however, is that the Browse page requires ProjectViewModel, where Upload uses UploadViewModel, etc. etc. So b...

WPF: Dependency Properties and DataContext

I was working on creating a reusable custom control (not a user control) in WPF. I created the XAML in the Themes/Generic.xaml file and I setup the "lookless" functionality in the control's CS file: AddressField.cs using ...; namespace MyNamespace { [TemplatePart(Name = AddressField.ElementAddress1TextBox, Type = typeof(TextBox...

How to set datacontext to silverlight control from aspx page?

Hi, How can I set the data context for silverlight control from aspx.cs? In other words, I want to set viewmodel for silverlight control from outside. Please let me know if anyone has done it before? ...

Access DBEntities in enhancement of partial EDMX class (.NET 4.0)

Building a little test application using ADO.NET Entity Framework, I've extended my auto-generated edmx data model classes. In particular, I've added a partial class to my Actors model Partial Public Class Actors Implements IEquatable(Of Actors) .... Public Sub refreshCountse() Dim q = (From p In Movies Where p.ac...

DataContext for LINQ to SQLite via System.Data.Sqlite

I'm fairly new to LINQ and trying to find a more elegant way (other than ADO.Net) to query and manipulate data in a SQLite database. I'm using System.Data.SQLite and wondering if there is a DataContext class or a way to use DataContext class to work with SQLite. I believe LINQPad uses the same assembly for its SQLite/MySQL driver and wi...

LINQ to SQL - There is already an open data reader associated with this command whic must be closed first.

Hi, Recently i implemented Linq to SQL in a static class in my ASP.Net project which is a utility class to get some information on site load. when i used the static linqtosql datacontext i got the above error only in the live environment but never got that issue on UAT, or QA sites. ( this means this issue only happens when there is a m...

How to define DataContext in XAML using StaticResource

I want to declare a DataContext through a static resource in XAML as a binding for the Customers in the Northwind database. I can do this easily in code (C#) but want to learn how to do in XAML. I have tried all of the examples I can find but none of them work for me. I believe the issue is in the two XAML lines of code I have labeled [O...

How can I wrap tables into a more generic class for use with multiple data contexts?

I have two different DataContexts (SQL Databases) that have the same data, just with slightly different naming: DB1: Serialnumber Productnumber DB2: SerialNumber ProductNumber Result So I want to be able to wrap these tables in a class that will let me get back the serial number and product number regardless of the DataContext that it ...

WPF: DataContext dependency property in non - GUI - classes?

Is it possible to have a dependency property "DataContext" in a class that is NOT derived from "FrameworkElement" (but it can be derived from "DependencyObject")? I already tried and created a class (which I added to Window.Resources), but the DataContext is always null. Any ideas? ...

why can't the datacontext detect changes to controls binded to a dataview when these changes are done via js?

I created a javascript AdoNetDataContext and created a DataView from it. I was using textboxes on the template for the table columns. AdoNetDataContext can track changes if there were any on the textboxes corresponding to the table columns used. But my changes to the textbox are done via jquery. The thing is, datacontext does not recogni...