.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Adding items to ObservableCollection via DataGrid

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :WPF
Hi All, I have a DataGrid bound to an ObservableCollection. I'd like to be able to add objects to the collection via the Grid. When I was working with sample data, I could go to the bottom of the grid, hit enter and add a new entry. Now that I'm using real data I don't seem to be able to do that. I tried taking a look at the class that the SampleData creates and can't quite fathom what it's up to. Does anyone know what I'm missing \ what I need to implement to make this possibe? Thanks Warrick

View Complete Post

More Related Resource Links

Adding new items to a Repeater control with transitions?



I am currently in the process of writing a facebook type 'activity feed' for a site. Currently I am binding the last 10 items to a repeater control, which contains a usercontrol representing each item. This works fine but there are a couple of requiremnts that are giving me problems and wondered if the the good people of the forum could make some suggestions.

The requirement is that when a user clicks a refresh button any new events are added to the top of the list, the previous items drop down and the equivalent number of old items drop off the bottom, all with nice slider transitions.

I have put the repeater inside of an update control and are able to handle the transitions by using RegisterStartup script to drop jquery calls onto the page for the slider. However I cannot find a way to dynamically add or remove new datarows to the repeater. I need the old items to stay in the repeater and be pushed down by the new items, so completely refreshing the datasource seems like a bad idea.

I was thinking about maybe storing the datasource in the viewstate and adding rows to that, maybe with an extra column on the end which stores what transition is needed on the databind for my jquery, but there will be a 'View more items' link at the bottom of the page, so I am worried that the list could get pretty large and there

Way of adding items in Drop Down List or List Box using Javascript

The article Way of adding items in Drop Down List or List Box using Javascript was added by raja.s on Sunday, June 06, 2010.

Hi,script type="text/javascript"> function AddItem(Text,Value) { // Create an Option object var opt = document.createElement("option"); // Add an Option object to Drop Down/List Box document.getElementById("DropDownList"

Video: Adding SharePoint 2010 Project Items to a C# or VB.NET Project

Each project is either a C# or VB.NET project that contains particular initial project items. In addition Visual Studio 2010 includes SharePoint project items that you can add to any of your projects. (Length: 18:53)

Adding, removing or editing the items of combobox.....

Hello everyone, I am working on this application which requires Items of the combobox added, edited or removed by the end user in the different section of the application such as settings window or something like that. I guess If we bind the Combobox to the database where we could easily add , remove or edit the items of combox but for the application that doesn't use database that creates a lot of overhead. To demonstrate that Here is my sample application Window1.xaml <Window x:Class="MySampleApplication.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" Title="Window1" Height="300" Width="300" xmlns:local="clr-namespace:MySampleApplication" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> <Window.Resources> <local:StringsLenToBooleanConverter x:Key="mvc"/> </Window.Resources> <Grid> <ComboBox Height="26" Margin="12,75,12,0" Name="comboBox1" VerticalAlignment="Top"> <s:String>Red</s:String> <s:String>Blue</s:String> <s:String>Green</s:String> </ComboBox> <Button Height="28&quo

In a group calendar, can items be made visiable to all users by default without adding them as atten

Well the title says it all really. We have a functioning sp 2010 site, setup this weekend, that's working great so far.  Primarily its being used for the company manual and procedures (a wiki site).  Search is working well and so on. I added a calendar with the intention of showing key company activities, plus holiday information and who's out at meetings.  We're a small company and this is unlikely to get ridiculously except on exceptional days. As it stands, when i create an item (for example someone out for a weeks holiday) unless another user adds one of the 'attendees' of the holiday event to the calendar it doesn't show up.  If I add all users as attendees then they can all see it by default. However, if I show that our chairman is attending a meeting at a client, then I can't explicitly say that the chairman is an attendee because for everyone to see it, they have to be attendees as well. I nsoed around a little and thought target audiences might be the way to go.  I configured all users and manager relationships, compiled the audience (it shows the right number of users).  However, if I setup a meeting with the chairman as an attendee, and the whole company audience as the target audience, then people still can't see it. Back to square one. So, is there an actual answer to this?  A different type of calendar, a query that

Adding new rows to Datagrid with a Combobox column generate "two-way binding requires path or xpath"



    I have datagrid control with a template combobox column like:

 <DataGridTemplateColumn Header="Fault code" Width="75">
                                    <TextBlock Text="{Binding FaultCode1}" />

IE9, Site Specific Browsers, and adding your own Jump List Items to Pinned Tabs

Site Specific Browsers aren't a really new idea. In 2005 there was an app called Bubbles I ran for a while that would let you run a website with minimal "browser chrome." Mozilla Prism (né WebRunner) is a Firefox add-in that does a similar thing. Google Chrome includes the idea of Application Shortcuts. The idea of all this is that some web apps are really applications and you think about them as applications. For me, I think of Gmail and Facebook and Twitter and Basecamp as applications not necessarily as browser tabs. The notion of Site-Specific Browsers is definitely arriving. Internet Explorer 9 Beta (IE9) is out now and includes a featured called " Site Pinning " which is a effectively Site Specific Browsers. It's...(read more)

Problem when adding items to a listbox from different threads


I have an application in which different threads add items to a listbox throughout the application's execution (not at startup). But when one of the threads tries to add an item to the listbox, a System.InvanlidOperationException is thrown and the error message is: "The calling thread cannot access this object because a different thread owns it." (In my scenario the "calling thread" is one of the worker threads that add items to the listbox, and the "different thread" is the UI thread.)

So basically I just need a simple way to allow the threads to share the listbox object, or, failing that, some other workaround.

Adding Items to ListBox with animation



I have the following code:

<DataTemplate x:Key="DataTemplate1">
		<EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="textBlock">

" 'System.ArgumentOutOfRangeException' occurred in PresentationCore.dll " while adding items to Ob

I have custom workflow designer in wpf application.
So there is a toolbox with activities.
I have collection of toolbox items in toolbox:

public ObservableCollection<WorkflowToolbox> Items
            get { return (ObservableCollection<WorkflowToolbox>)GetValue(ItemsProperty); }
            set { SetValue(ItemsProperty, value); }

// Using a DependencyProperty as the backing store for Items.  This enables animation, styling, binding, etc...
 public static readonly System.Windows.DependencyProperty ItemsProperty = System.Windows.DependencyProperty.Register("Items", typeof(ObservableCollection<WorkflowToolbox>), typeof(WorkflowToolboxContainer), new UIPropertyMetadata(new ObservableCollection<WorkflowToolbox>()));

Then every time i close/open that component in UI this collection  is cleared and populated with new items.

WorkflowToolbox toolBox = new WorkflowToolbox { DataContext = assembly };

And after 2 open/reopen i had ArgumentOutOfRangeException with stack trace:
   at System.Windows.Me

Help Moving Datagrid items with Up and Down arrows!!



I need some help.  I have a datagrid that has photos and a description of the individual in the photo.  I have a procedure that works and if I execute it with the correct parameters it changes the rows in the table.  I have a datagrid with two image buttons, MoveUp and MoveDown.  I just want to be able to reorder the photos when needed.

In my proc called "MoveMember" I have these parameters that are passed in.  The column that gets swapped in my table is the "OrderBy" column, they are just numeric numbers 1,2,3,4 etc.

So in my procedure 2 and 3 can be interchanged. 

@FMFacultyID INT,
@FMFirstOrderBy INT,
@changeValue INT,
@FMSecondOB INT 

Adding Items to existing list using CAML

Does anyone know how to add list items (not files) to a SharePoint list using CAML?  I know how to do this in code but I was curious if it was possible in CAML. We can add files using the Module element quite easily and so I thought, why not list items?  It is possible to add list items to a new list using the Data element, but I am trying to add items to a list created earlier by another feature.

ObservableCollection to Datagrid in WPF


Hi All,


I'm newbie to programming. Now I just playing and learning.

I've made a WebService about this video tutorial: http://msdn.microsoft.com/en-us/netframework/first-steps-with-wcf.aspx

Everithing works fine. I've extended this with a little entity framework. Created a database and now my WPF client gets the data from my SQL database.

In my WPF clien I use DataGrid to show a few thing. I've heard I should use ObservableCollection as the itemsource and then for example if I submit a new record my list will refresh automatically and I get other cool things...

I need some help about this task. I don't really understand how could I implement this.

I'd like to show a few code snippet and ask somebody help me to rewrite my code to use ObservableCollection.

Well lets see the code snippets:

I generated my database from model definition. The generation created a class called EntityDB. EntityDB has a few properties like UserName, Password etc...

In my interface definition I have a methode defined:

List<EntityDB> GetPasswds();

The metho

Adding windows forms controls to the display of list items



I'm new to Sharepoint development, and was wondering if I could get some brief pointers to get me going in the right direction.  I'm required to add a button to list items that on submit does some manipulation of the data in the fields inside the item and then sends that data off to an external webservice.  The complexity is sufficient to warrant managed code, i.e. C#.

What I'd like to know is how to approach integrating this code into Sharepoint.  I've read about web parts, but viewing list items doesn't involve web part pages on my installation so I can't include my own.  What other ways are there of doing this?

Cheers all

DropDownList in the FooterTemplate of a DataGrid will not show its items


I am placing a dropdown list in the footer of a DataGrid like this:

<asp:DataGrid id="MyGrid" runat="server">
            <asp:DropDownList ID="myDDL" OnLoad="myDDL_OnLoad" runat="server" />

In my code behind file, in the myDDL_OnLoad event handler, I call to the database, populate a SqlDataReader, and set the DDL's datasource to that datareader. I define what data columns should be used for the DataValueField and DataTextField of the dropdownlist. Then I call the DropDownList's DataBind() method. Everything works without error. But, when the dropdownlist is displayed, it has blank lines in it.

By that, I mean if 8 records are loaded into the dropdownlist, it will expand to a size appropriate for 8 rows but, it will be empty. there is no text in it.

Has anyone seen this type of behavior before? This dropdownlist is in the footer of a dynamically loaded ajax update panel so, it is difficult to see the source code to see what values are in the html element rendered to represent the dropdown.

Thanks in advance for any advice you can give.

WPF DataGrid.Items.Refresh Exception


I am getting this exception when calling the Refresh method of a datagrid.items.  Any clue how to solve this?

This is the message:  'Refresh' is not allowed during an AddNew or EditItem transaction


How to re-enable virtualization in WPF DataGrid after adding, then removing a GroupStyle ?


I would like to use grouping, with an ObservableCollection, in the WPF DataGrid. 

Unfortunately, adding the GroupStyle causes virtualization to be lost.

What I can do, which I believe would help quite a bit, is to add the GroupStyle programmatically when grouping is requested, then remove the GroupStyle when the list is un-grouped.

I found out though that removing the GroupStyle doesn't re-enable virtualization.

Can someone tell me how to re-enable virtualization? 

Thank you very much!

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend