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

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

Binding Text contains "comma separated items" to a checked list box

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :WPF

Stundent record contains a text field, this field contains a comma separated courses that the student have.
I designed a WPF form showing that field and alos a cheched list box showing all available with some items checked according to that text field. here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MicrosoftCourses
  /// <summary>
  /// Interaction logic for MainWindow.xaml

View Complete Post

More Related Resource Links

text box binding with Generic list

Hi, I am working in asp.net 3.5 page, where I want to bind a textbox with generic list data. And I have Previous & next button. Which will show the record in textbox. I don't want to go in db again and again.  Is it possible.??? 

Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

FormView Text Field Being Set by A Drop Down List


Hello, I have a FormView which is used to insert a record into a database.  Outside of this formview i have a drop down list, I want to grab the value from that drop down list and set one of the text fields within the formview to it's currently selected value.  I've tried the following code, but the dynamic categorytextbox line is what seems to not be working.

                    <asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" 
DataSourceID="SqlDataSourceCategory" DataTextField="CategoryName"
DataValueField="CategoryID" Width="200px">

                            <asp:TextBox ID="CategoryIDTextBox" runat="server" 
Text='<%# Bind("CategoryID") %>' Visible="False" />

        protected void FormView1_DataBound(object sender, EventArgs e)
dynamic varCategory = ddlCategory.SelectedValue;
dynamic categoryTextBox = FormView1.FindControl("CategoryIDText

Disregarding updates on non-checked-in entries in a sharepoint list (SPAudit)


Hey guys.

Okay, this is a little hard to explain, as the title might suggest.

I have an event receiver on ItemUpdated and ItemCheckedIn, which both writes custom SPAuditEntries. When CheckedIn occurs though - it comes with two update entries as well (one for added file, and one for a simple update to the list item I suspect).

I'd love to get rid of these entries. At first I thought it would be really simple, just put an if in the itemUpdated event receiver, and stop everything

if(SPListItem.CheckedOut = false) { //... do nothing }

However I couldn't find any way to ascertain the checkout-status of the listitem. My next thinking was, they hit almost at exactly the same time, so I could just crawl into the auditCollection, filter down to the specific listitem, user, and time (minus a second) and delete the two entries. But, sadly I found out I couldn't delete auditentries.

Anyone got any ideas?

How to read a column of a sharepoint list to a text string field of infopath form?

My infopath form used to read these email addresses from a web service and web.config file. Now i would like to get these user email addresses from a contact list in a sharepoint server. I am trying to do this without writing any codes. Here is what i have done so far: 1. Adding a new "data connection to receive data from SharePoint library or List" where i selected Email Address column of the contact list. 2. I added a new Text Field and define a new rule with "Query using a data connection" defined above. When i try to access the newly created Text field above it always return empty as if the Query attached to it did not executed at all. What did i do wrong? Is there a better way? Thank you in advance for your help.

Binding to child list

I have a wpf datagrid that is bound to my business object, Caregivers, which is a custom list of Caregiver.  The Caregiver object contains a child list, ScheduleList, which is a custom list of Schedule. I have successfully bound the datagrid to the Caregivers object using a collectionviewsource and setting the source to my custom object.  I now want to bind the datagrids row details to the child list but I am having trouble.  Here is what I'm trying: My Datagrid is:      <DataGrid Name="DataGridSummary" ItemsSource="{Binding}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" > <DataGridTextColumn Header="Name" Binding="{Binding Name}"/> <DataGrid.RowDetailsTemplate> <DataTemplate> <Border Margin="5" Padding="2" BorderBrush="DimGray" BorderThickness="0" CornerRadius="3"> <DataGrid Name="DataGridDetails" ItemsSource="{Binding ScheduleList}" HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" AutoGenerateColumns="True" CanUserAddRows="False" CanUserDeleteRows="False"> <!--<DataGridTextColumn Header="Clie

TextBox shows binding source text when window load, so why not with the ComboBox?

How can I get a ComboBox to show the binding source value when my window opens?  I have been searching all day for a solution to this, but cannot find anything.  So I have created a sample project to demonstrate my problem.  Below is a Vehicle class, very simple, two members Category and Make.  Category is an enumeration, Make is a string. namespace ComboExample { public class Vehicle { // Constants and enumerations public enum eCategory { Road, Air, Sea } // Attributes public eCategory Category { get; set; } public String Make { get; set; } // Construction public Vehicle(eCategory Category, String strMake) { this.Category = Category; this.Make = strMake; } } } Here is the C# for the MainWindow.  A new Vehicle object is created as a member.  In the constructor I set a data-provider in the XAML to this Vehicle object.  There is a button event for showing the values of the controls and objects so I can check the binding. namespace ComboExample { // Interaction logic for MainWindow.xaml public partial class MainWindow : Window { // Attributes Vehicle m_Car = new Vehicle(Vehicle.eCategory.Road, "BMW"); // Construction public MainWindow() { InitializeComponent(); // link data-p

Data Binding a DataGrid to a list fetch the same data multiple times

Hi, I'm using DataGrid to show data through data binding. My data are provided in a list. The setup I have is the following: DataGrid "binded" to the default view of my list that implement IList<T> and IList interfaces (MyList<T> : IList<T>, IList, INotifyCollectionChanged)             CollectionViewSource.GetDefaultView(_myList);             // Set the data context             DataContext = view; T: is here my 'business object' that hold the data, called 'MyRow'. Then the columns of the DataGrid are bound to public properties of 'MyRow' object. MyRow class has a public property of type 'object' (public object data[int index]) and first column of datagrid is bound to myRow.data[0], second column is bound to myRow.data[1] and so on.   When the datagrid is displayed, databinding kick in and my data are showed in the control. The issue I'm having is that data fetching is very repetitive even for the same rows. For example for a datagrid with 20 visible rows, the first row is fetched multiple times even if the datagrid is not resized or moved. I put break point inside my list (MyList<T> into This[T] property (public T this[int index]) and i got multiple hits into the property for the same index. Fetc

How to get selected text of a drop down list in MVC?

I aggressively googled around, but could not find the information I am looking for.  I know how to populate a dropdownlist using my view model and Html.DropDownListFor helper method.Suppose the drop down list contains U.S. stateId and stateName key value pairs.  Suppose my ViewModel looks likepublic class MyViewModel{      public IList<State> States {get; set;}      public int SelectedStateId {get; set; }}public class State{     public int StateId {get; set; }     public string StateName {get; set; }}Now, in my controller's action method:[HttpPost]public ViewResult Index(MyViewModel  myViewModel){     // This following line seems to work fine, myViewModel automatically      // picks up the selected item of the drop down list.  How does this work?      // Is this the so-called model binding?      int selectedStateId = myViewModel.SelectedStateId;      // But, then, how do I get the selected state name?     string stateName = ??????????????     ... ... }Do I have to change my implementation of my view model?  In any case, how to get the selected item text of the drop down list?  Any hint?  Thanks a lot.

Query Sharepoint list, rich text columns returning HTML tags

Hi! So I have an issue that maybe someone of you have encountered as well. I am querying a Sharepoint list and creating a report from the data collected from this list. This all works fine except that one of the columns in this list is of the type "Multiple lines of text" and also supports "rich text" with different fonts, sizes and so on. This has the effect that the text returned from this column is wrapped in HTML tags that specifies how the text should be formatted. Naturally I do not want this HTML code to appear in my report so for now I have used custom code to do a string.replace and replaced for example <div></div> and <br> with "". However, this column also has url references to documents and these links shows up like this "/servername/site/subsite/Gemensamma%20dokument/Mwh.docx">http://servername/site/subsite/Gemensamma%20dokument/Mwh.docx There is some sort of double reference to the document that I guess like the HTML tags are embedded in the answer from the rich text column and this is not so easy to do a string replace on because the url varies with the different document and document names. My question really is if anyone of you have done a similar report that I am doing, and have encountered this fenomen with this sharepoint column and how you did to solve this? I have tried to creat

Binding combo box to List box

Hi,      I am fairly new to WPF and i am trying to bind two controls on a page.  What i have is a combo box with one datacontext and a listbox with another.  What I am trying to do is when you select an item in the combobox it will filter the listbox by that selected item.  Below is the xaml for the listbox and the combo box.  the data is the combo box is a code and description.  The code in the list is a key ( the code) and a list of items for that code. Thanks in advance Art <   ComboBox Margin="0.027,23,80.682,0" Name="cboTraitParam"   ToolTip="Select a security Trait to specify for your autobid filter"   Height="22.168" VerticalAlignment="Top" Grid.ColumnSpan="5"   IsSynchronizedWithCurrentItem="True"   ItemsSource="{Binding}"   ItemTemplate="{StaticResource Muni_dropList}"   Grid.Column="1" /> <   ListBox   Name="ParamList" MinWidth="169" SelectionMode="Multiple"   IsSynchronizedWithCurrentItem="True"   ItemsSource="{Binding ElementName=cboTraitParam,   Converter={StaticResource SecurityParamConverter},   Path=SelectedValue }"     Margin="6,111,0,

Rich Text in list forms & date picker

Hi, I was hoping that someone could help me on a few issues. I have created a custom list form in sharepoint designer to display the contents of my list in a nice format. I have also customised the edit form for the list. I am having a problem with special characters now showing up when they are being entered (the HTML does not seem to be parsed on the output). I would like to make a description field in my list edit form a rich text box, is this possible? This is the code I am using at the moment for the text box: <asp:TextBox runat="server" id="ff5{$Pos}" text="{@status}" textmode="multiline" __designer:bind="{ddwrt:DataBind('u',concat('ff5',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@status')}" Width="600px" Height="100px" /> And this is the code that I am using on the display side of the list to show the status update: <xsl:value-of disable-output-escaping="yes" select="ddwrt:AutoNewLine(string(@status))" /> Is there code that I can use on the data entry side that will show a rich text box? Also then I will need to change the tag on the display end so it parses the HTML? In addition to this, is there specific code for a 'date picker' ? At the moment my date entry box is just a standard text box, is there code I can u

Binding list to form not working with '&' character in list field data

Hi, I have a SharePoint list with a field called Title. I have a form based on this list with the field bound to the form as a label (for workflow to access). Here is the code for the form field. <asp:Label runat="server" id="ff2{$Pos}" text="{@Title}" __designer:bind="{ddwrt:DataBind('u',concat('ff2',$Pos),'Text','','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}" /> I have a workflow that runs through a form action button which take ff2 (title) and  does other stuff. The problem I have is with records where the value of 'title' contains the '&' character (example ab&cd). Blank is pulled in by the workflow when I get the value of ff2. I am guessing it has to do with the data binding and/or escape (special) characters coming through but I don't know how to fix it. Any help will be greatly appreciated

how to get list box all option in a text box using jquery


i crate a list box by database but i want all option in a Text box

<td><select name="ListBox1" multiple="multiple" size="8" id="ListBox1">
		<option value="">Select</option>
		<option value="1001">1001.Ashok</option>
		<option value="1002">1002.Rajiv</option>
		<option value="1003">1003.Garima</option>
		<option value="1012">1012.Akhil</option>
		<option value="1011">1011.Nasir</option>

how i do it

<td><select name="ListBox1" multiple="multiple" siz

How to get text value of dropdown list box by passing index value


how to get text value of dropdown list box by its index.

i want to read the ddlproject.selectedindex = 0's text and assign it to a variable strProject.


Thank you very much for the helpful info.

Drop down list not data binding




I am trying to data bind a drop down list inside a formview but for some reason when I click the update button I get the follwoing error message:

'ddl_activity_status' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 'ddl_activity_status' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentOutOfRangeException: 'ddl_activity_status' has a SelectedValue which is inval
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