.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

Problem whit ComboBox binding in WPF

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :WPF
Here are my main classes: Configuration { List<Environment > EnvironList, Source ConfigSource } Source { List<FileSource > FileSourceList } FileSource {} inherits class     SourceInfo { string Id, string Source } Environment { List<FileDestination > EnvirFileList } FileDestination { List<String> DestinationList } and inherits class     Info { string SourceId } Info .SourceId refers to SourceInfo .Id. Example: Id="mySource" Source="C:\PathToMyFiles" The Configuration is read from an XML file. In my display, I want to gatter all the SourceInfo objects of my Configuration and put them in a comboBox, to be available for selection in the Environment ->FileDestination ->Info .SourceId. So far, no problem. I also want to select the current value. I did that by putting it at the begining of the list and selecting that index when the list is created. The problem I have is when I try to modify the value. When I change the selection, it shows me the new value, but that value is never saved. If I reload the list, the old value is selected. Also, when I add a new File in the  Environment .EnvirFileList, the SourceId is never added to the XML file. That XML file is create with Serialized properties from my classes. If I remove the ComboBox and use a textbox, the value is added to the XML file. Below is

View Complete Post

More Related Resource Links

ajax combobox having problem in binding data

Hi i am using ajaxtoolkit:combobox and i tried to bind data to this control in code behind file. but it is taking 3 to 4 mints to bind data and display the page. what is the problem? I am providing my aspx code and code behind code here<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="Dashboards_TestPage" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server"> <asp:ScriptManager runat="server" ID="scriptMgr"> </asp:ScriptManager> <table border="1"> <tr> <td> <ajaxToolkit:ComboBox ID="ddlProgram" runat="server" DropDownStyle="DropDownList" AutoCompleteMode="SuggestAppend" CaseSensitive="False" MaxLength="10"> </ajaxToolkit:ComboBox> </td> </tr> </table> </asp:Content>  Code behind code:public partial class Programs_TestPage : System.Web.UI.Page { ProgramData programData = new ProgramData(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack)

WPF ComboBox Binding problem



I have combobox that is has its itemsource bound to a list returned from DB, as follows




ComboBox Name

Binding value to combobox or dropdown


How can we bind a value to a combobox or dropdown? What is the property for binding a value? 


wpf charting column series data binding problem

I'm trying to build a chart using the columnSeries from the wpf toolkit and I appear to be having trouble with the data binding. Here is the xaml: <Grid>    <chartingToolkit:ColumnSeries Height="18" HorizontalAlignment="Left" Margin="188,169,0,0" Name="columnSeries1" VerticalAlignment="Top" Width="18" IndependentValueBinding="{Binding Path=Date}" DependentValueBinding="{Binding Path=Value}" /></Grid> In the code behind, I'm calling a stored procedure and putting the result in a datatable like this: string connString = ConfigurationManager.ConnectionStrings["string"].ConnectionString;            using (SqlConnection cn = new SqlConnection(connString))            {                DataTable dt = new DataTable("T1");                cn.Open();                SqlCommand cmd = new SqlCommand("T1_sp", cn);                cmd.CommandType = CommandType.StoredProcedure;                  SqlDataAdapter da = new SqlDataAdapter(cmd);                da.Fill(dt);                columnSeries1.ItemsSource = dt.DefaultView;                cn.Close();            } No error is being generated but I'm not getting a column chart either. If I take the same command and put it into a datagrid, it works fine. What do I need to do to get this into my column chart? If it helps,

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

Element Binding - ComboBox

  <ComboBox Height="23" HorizontalAlignment="Left" Margin="139,59,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" > <ComboBoxItem Content="Spain"/> <ComboBoxItem Content="England"/> </ComboBox> <ComboBox Height="23" HorizontalAlignment="Left" Margin="139,154,0,0" Name="comboBox2" VerticalAlignment="Top" Width="120" > <ComboBoxItem Content="Madrid"/> <ComboBoxItem Content="Barcelona"/> <ComboBoxItem Content="London"/> <ComboBoxItem Content="Birmingem"/> </ComboBox> I've problem... I want to use element binding, in this source to filter Cities by selected Countries how do it?  

Problem Binding DropdownList in a gridView to a datasource

I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).<asp:TemplateField HeaderText="Category"> <ItemTemplate> <asp:DropDownList ID="Cat" runat="server" SelectedValue='<%#Bind("CATEGORY") %>' > </asp:DropDownList> </ItemTemplate> <FooterStyle BorderStyle="None" /> <HeaderStyle BorderStyle="None" /> <ItemStyle BorderStyle="None" /> </asp:TemplateField>How do I do that? thanks in advance!

WCF protocol binding on htttp://* problem

Hello, has anyone found a solution to this famous Visual Studio 2008 problem with WCF debugging? It's in other threads of the forum, http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/782a48a2-a44c-4ced-934b-715c2e4cb6a4 http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/41630af1-37ec-411f-969b-3e857f978279/ but it's never really been answered. I have been looking for a solution for some time, but I haven't found anything. The problem is always the same: The VS internal web server every now and then gives an error saying NO PROTOCOL BINDING MATCHES THE GIVEN ADDRESS '' and the only solution to the problem is to reboot the machine. Changing web.config doesn't work, restarting Visual Studio neither. Any ideas anybody?

Problem with Binding Dictionary to Combo Box Control

Hi All,I am trying to figure out how to bind <Key,Value> pair to Combo Box Control in WPF. By now i have found that the following code do not hold Keys in the comboBox:[vb Code]Dim MyDictionary as Dictionary(OF String,String)MyDictionary.Add("Key1","Value1")MyDictionary.Add("Key2","Value2") ..etc.'***** MyComboBox is ComboBox control ******MyComboBox.ItemSource =  MyDictionary.Values[xmal]<xmls:ComboBox x:Name="MyComboBox" />Doing the above process does not fulfill my purpose of capturing keys. Example if i want to get the "Key" for "selectedItem" then i cannot since i have not binded it.Can anyone suggest me a solution? If anyone can provide me with a xmal and code behind that would be great!!!THanks in Advance.

FormView custom data binding problem

Hi there,   I'm using VWD 2010 ASP.NET 4.0 and SQL Server 2008 Also I have login page with the ASP.NET configuration   one of my page has FormView with Update feature   Evryting works fine user login go to my FormView page and update the record.   Now I created a simple function   Protected Function GetUserName() As String        Return User.Identity.Name    End Function   and one of my coloumn call EditedBy   I replaced the Bind("EditedBy") field binding with   Custom binding GetUserName()   When user update it show the current user login name on the screen But it won't show in the table itself (it show null value when i do select statement)   I used to do this with ASP.NET 2.0 with no problem?   How do I fix that?   Thanks, Oded Dror  

problem in make editable a combobox in datagridview in c#

how do i make my datagridview combobox aditable for the user while i has a drop down list. in this case sometimes user needs to edit the selected item from the list.how can i implement this?

Binding ListBox to ComboBox's SelectedItem

Hi All,   I have a ComboBox that is bound to a collection of People. When the user selects a Person in the ComboBox, I want a ListBox below that to be populated wtih the Person's Friends.   Is it something like:   <ComboBox x:Name="PeopleComboBox" ItemsSource="{Binding People}"/> <ListBox ItemsSource="{Binding ElementName=PeopleComboBox, Path=SelectedItem.Friends}"/>   I'm going for something like that.

GridView column/row data binding problem

Hi All, I have a table with the following structure: Attribute------------- AttributeIdWeekNoDayNoAttribute1Attribute2Attribute3Attribute4Attribute5 ........ likewise. I want to display these data in a gridview in the following manner                                  Sunday    Monday Tuesday ............ (till Saturday) - should be gridview columns, I can retrieve this using dayno Attribute 1 Attribute 2 Attribute 3 Attribute 4 .......... like wise attributes should be taken in to rows.Is this possible in a gridview, if so how can I do that?

Problem binding business objects to custom user control properties

I have created a user control (supplierPicker) intended to allows a supplier database to be searched and a supplier selected. I want to be able to use this control in a number of other user controls, by binding the suppplierID property of the supplierPicker to a supplierID property in a business object, which is set as the datacontext of the parent user control. When I do this, and there is a supplierID specified in the business ofbject, the binding sets the supplierID in the supplierPicker control and it shows the correct supplier name in the textbox. However when the supplierID DependencyProperty is changed from within the supplierPicker the newly selected supplier name is shown in the TextBox, but the SupplierID does not propogate back to the business object. Other controls on the parent form work fine, so the binding to the business object seems to be ok. Any pointers as to what I'm doing wrong here would be grately appreciated.  This one has been driving me nuts for days! Snipped code for the supplier picker:         public partial class SupplierPicker : UserControl, INotifyPropertyChanged     {         public static DependencyProperty SupplierIDProperty;         public event PropertyChangedEventHandler PropertyChan

Problem binding data to DropDownList in DetailsView

Hi guys. I have a slight issue I awas trying to fix for 2-3 days, but nothing I try works. The scenario: DetailsView control in edit mode, I pass parameters to the SqlDataSourceProducts (edit.aspx?id=2) and the data source selects the appropriate data and fills in the DetailsView form. Except two drop down lists. These two DDLs (DDL2 and DDL3) are dependent on the previous DDL (DDL1) in the DetailsView. Thanks to PeteNet, when the selected value of the DDL1 changes, DDL2 and 3 change their lists and get bound to the database. The problem is: when I edit something from the database, DDL2 and 3 appear empty and when I update any other field and leave these, they get blanked in the database.  My goal is to set the selected value of DDL2 and 3 to the values in the database WHERE ID = QueryStringField="id". I can go for not binding the data unless the field is changed, but does not sound professional and user friendly. code: The SqlDataSource used to select the parameters from the table and populate the DetailsView <asp:SqlDataSource ID="SqlDataSourceProduct" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT ID, wm_number, upc, check_digit, unit, price_unit, brand, category, shelves, type, cooking, storage, packaging, origin, nutriti

WCF - Java web service interop - Problem with asymmetric binding

Hi, I try to communicate with a Java web service and run into the following error: Error: System.ServiceModel.Security.MessageSecurityException: The incoming message was signed with a token which was different from what used to encrypt the body.  This was not expected. Server stack trace:    at System.ServiceModel.Security.TokenTracker.RecordToken(SecurityToken token)    at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlDictionaryReader reader, Int32 position, Byte[] decryptedBuffer, SecurityToken encryptionToken, String idInEncryptedForm, TimeSpan timeout)    at System.ServiceModel.Security.ReceiveSecurityHeader.ExecuteFullPass(XmlDictionaryReader reader)    at System.ServiceModel.Security.StrictModeSecurityHeaderElementInferenceEngine.ExecuteProcessingPasses(ReceiveSecurityHeader securityHeader, XmlDictionaryReader reader)    at System.ServiceModel.Security.ReceiveSecurityHeader.Process(TimeSpan timeout, ChannelBinding channelBinding, ExtendedProtectionPolicy extendedProtectionPolicy)    at System.ServiceModel.Security.MessageSecurityProtocol.ProcessSecurityHeader(ReceiveSecurityHeader securityHeader, Message& message, SecurityToken requiredSigningToken, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)    at System.ServiceModel.Security.AsymmetricSecurity

combobox backcolor problem

hi i have a problem with combobox back color and numericupdown. why combo box backcolor changes to another color (default back color) when their enable have set to false?   tanks
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