Search Results

Search found 854 results on 35 pages for 'databinding'.

Page 21/35 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • ASP.NET ListView, custom DataSources, and editing items

    - by Andrew Shepherd
    The MSDN walkthroughs provide a number of examples where you can drag a DataSource from the toolbox, run through some simple configuration steps, then drag a ListView onto the screen, point it at the DataSource, and hey - you've got full table editing. Now I'm trying to write my own DataSource class (a class that implements System.Web.UI.IDataSource) and my own DataSourceView class. I now assign an instance of this custom DataSource class to the ListView.DataSource propery. The display of all the items is working well. However, updating, inserting and deleting just is not working. I'm overriding every function I can in my DataSourceView class, and they just aren't being called. This is such a huge topic, I'll focus this question on one simple example: When you press the "Edit" button (the button inside the ItemTemplate with a CommandName of "Edit", you expect the ItemTemplate to be replaced by an EditItemTemplate. This did not happen. The only way I could get it to happen was to handle the onitemediting event. protected void _listViewPublicHolidays_ItemEditing(object sender, ListViewEditEventArgs e) { _listViewPublicHolidays.EditIndex = e.NewEditIndex; _listViewPublicHolidays.DataBind(); } This is hardly a problem, but how come I had to do it at all? In the MSDN walkthroughs where I attach a ListView to a LinqDataSource, this code doesn't have to be written. Can someone who's been here before hazard a guess as to what would be different or missing in my custom datasource?

    Read the article

  • Combobox INotifyPropertyChanged event not raised!!!

    - by nagiah
    I created a combobox and set observable collection as the itemsource and implemented INotifyPropertyChanged on the observable collection item. Even after that, when I select different item in the combobox, the OnPropertyChange method is not invoked. I think I am not making the binding properly. Could any one please correct me/ suggest me in this regard. ---------------------------------MainPage.xaml--------------------------------------------------- <StackPanel Width="300"> <ComboBox Name="cboName"></ComboBox> <TextBox Name="tbxName" Text="{Binding Path=name,Mode=TwoWay,ElementName=cboName}" ></TextBox> </StackPanel> ---------------------------MainPage.xaml.cs----------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; namespace MasterDetailsUpdate { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); Loaded += new RoutedEventHandler(MainPage_Loaded); } void MainPage_Loaded(object sender, RoutedEventArgs e) { ObservableCollection<Person> persons = new ObservableCollection<Person>(); persons.Add(new Person { city = "c1", name = "n1" }); persons.Add(new Person { city = "c2", name = "n2" }); persons.Add(new Person { city = "c3", name = "" }); persons.Add(new Person { city = "c4", name = "" }); persons.Add(new Person { city = "c5", name = "n1" }); cboName.ItemsSource = persons; cboName.DisplayMemberPath = "name"; } } public class Person : INotifyPropertyChanged { private string _name; private string _city; public string name { set { _name = value; OnPropertyChanged("name"); } get { return _name; } } public string city { set { _city = value; OnPropertyChanged("city"); } get { return _city; } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } } Thank You

    Read the article

  • How do you use data binding in C# development ?

    - by MemoryLeak
    Recently I use data binding to speed up my development of C# winforms application. But I found that data binding is just useful when the control is Textbox or textare and text kind of controls. If things come to be radio button, image control or datagridview, it's hard for me to use data binding. For example, it's hard for me to bind a group of radio button to a database field. It's hard for me to pre-process the data in database and then bind to datagridview control(I know I can use view to do this, but it is not that convenient) So I really want to know, most of you guys when will use data binding? And how will you use it ?

    Read the article

  • Get invalid user input with a Spring typeMismatch error

    - by TimmyJ
    I've implemented a ReloadableResourceBundleMessageSource in my Spring MVC application which I use to display prettier error messages for binding exceptions. The problem I'm having is that, due to a company policy, these errors must be displayed in the following format: [inputData] is not a valid [fieldName]. The field name is accessible by default in my message properties file (as the {0} argument), but I can't figure out a way to display the invalid user input. Is this possible?

    Read the article

  • WPF validation on Enter Key Up

    - by Martin
    I'm trying to validate a UI change when Enter key is pressed. The UI element is a textbox, which is data binded to a string. My problem is that the data binding hasn't updated TestText when Enter key is Up. It is only updated when I press the button which brings up a message box. /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window, INotifyPropertyChanged { String _testText = new StringBuilder("One").ToString(); public string TestText { get { return _testText; } set { if (value != _testText) { _testText = value; OnPropertyChanged("TestText"); } } } public Window1() { InitializeComponent(); myGrid.DataContext = this; } private void OnPropertyChanged(string property) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(property)); } } public event PropertyChangedEventHandler PropertyChanged; private void onKeyUp(object sender, KeyEventArgs e) { if (e.Key != System.Windows.Input.Key.Enter) return; System.Diagnostics.Trace.WriteLine(TestText); } private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show(TestText); } } Window XAML: Window x:Class="VerificationTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" KeyUp="onKeyUp" TextBox XAML: TextBox Name="myTextBox" Text="{Binding TestText}" Button XAML: Button Name="button1" Click="button1_Click"

    Read the article

  • database text field databound to a checkbox

    - by Patrick
    I'd like the field to save as a 1 or 0 instead of 'True' or 'False' in the database and i cannot figure out how to do it without manually setting every property when the record is saved. I have to use this a lot in this project and a bit field is not an option. I would like to solve this issue by extending the CheckBox control if possible but i don't know how to change the binding fields value. Any help would be greatly appreciated!

    Read the article

  • how to insert an integer value from a Grid to Sql table?

    - by z-chaos
    Hi, I have a AdvWebGrid where the 7th coloumn is DynEdit where user will enter the value.Now I have to take the enetered value and insert into the Sql tablel. For example i have 7 records in the grid the user will enter some comments for the first three record and save.Now i have to insert/update the first three comments in the table.

    Read the article

  • Data bind enum properties to grid and display description

    - by TrueWill
    This is a similar question to How to bind a custom Enum description to a DataGrid, but in my case I have multiple properties. public enum ExpectationResult { [Description("-")] NoExpectation, [Description("Passed")] Pass, [Description("FAILED")] Fail } public class TestResult { public string TestDescription { get; set; } public ExpectationResult RequiredExpectationResult { get; set; } public ExpectationResult NonRequiredExpectationResult { get; set; } } I'm binding a BindingList<TestResult> to a WinForms DataGridView (actually a DevExpress.XtraGrid.GridControl, but a generic solution would be more widely applicable). I want the descriptions to appear rather than the enum names. How can I accomplish this? (There are no constraints on the class/enum/attributes; I can change them at will.)

    Read the article

  • web service filling gridview awfully slow, as is paging/sorting

    - by nat
    Hi I am making a page which calls a web service to fill a gridview this is returning alot of data, and is horribly slow. i ran the svcutil.exe on the wsdl page and it generated me the class and config so i have a load of strongly typed objects coming back from each request to the many service functions. i am then using LINQ to loop around the objects grabbing the necessary information as i go, but for each row in the grid i need to loop around an object, and grab another list of objects (from the same request) and loop around each of them.. 1 to many parent object child one.. all of this then gets dropped into a custom datatable a row at a time.. hope that makes sense.... im not sure there is any way to speed up the initial load. but surely i should be able to page/sort alot faster than it is doing. as at the moment, it appears to be taking as long to page/sort as it is to load initially. i thought if when i first loaded i put the datasource of the grid in the session, that i could whip it out of the session to deal with paging/sorting and the like. basically it is doing the below protected void Page_Load(object sender, EventArgs e) { //init the datatable //grab the filter vars (if there are any) WebServiceObj WS = WSClient.Method(args); //fill the datatable (around and around we go) foreach (ParentObject po in WS.ReturnedObj) { var COs = from ChildObject c in WS.AnotherReturnedObj where c.whatever.equals(...) ...etc foreach(ChildObject c in COs){ myDataTable.Rows.Add(tlo.this, tlo.that, c.thisthing, c.thatthing, etc......); } } grdListing.DataSource = myDataTable; Session["dt"] = myDataTable; grdListing.DataBind(); } protected void Listing_PageIndexChanging(object sender, GridViewPageEventArgs e) { grdListing.PageIndex = e.NewPageIndex; grdListing.DataSource = Session["dt"] as DataTable; grdListing.DataBind(); } protected void Listing_Sorting(object sender, GridViewSortEventArgs e) { DataTable dt = Session["dt"] as DataTable; DataView dv = new DataView(dt); string sortDirection = " ASC"; if (e.SortDirection == SortDirection.Descending) sortDirection = " DESC"; dv.Sort = e.SortExpression + sortDirection; grdListing.DataSource = dv.ToTable(); grdListing.DataBind(); } am i doing this totally wrongly? or is the slowness just coming from the amount of data being bound in/return from the Web Service.. there are maybe 15 columns(ish) and a whole load of rows.. with more being added to the data the webservice is querying from all the time any suggestions / tips happily received thanks

    Read the article

  • fix a columns width when a list is bound to a datagridview

    - by Andy
    I have a list that I have bound to a datagridview. I want the first column to be a fixed size. The data is bound to the dataGridView and I can't seem to find a way to access an individual colums properties. if I try myDatagridview.colums[0] I get an index out of bounds, since it says the columns count is 0. private DataGridView setUpDataGrid(List<NVRlineVal> _NVRData) { //setup dataGridView DataGridView NVRDataGridView = new System.Windows.Forms.DataGridView(); NVRDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; NVRDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; NVRDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; NVRDataGridView.Location = new System.Drawing.Point(3, 3); NVRDataGridView.Name = "NVRDataGridView" + nvrIndex; NVRDataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; NVRDataGridView.Size = new System.Drawing.Size(380, 401); NVRDataGridView.TabIndex = 0; NVRDataGridView.DataSource = _NVRData; var test = NVRDataGridView.Columns; NVRDataGridView.DataMember = "devState"; DataGridViewAutoSizeColumnMode.None; } Any ideas on how to have a fixed column width for only one of these columns, the rest will autosize?

    Read the article

  • What's the order of execution in property setters when using IDataErrorInfo?

    - by Benny Jobigan
    Situation: Many times with WPF, we use INotifyPropertyChanged and IDataErrorInfo to enable binding and validation on our data objects. I've got a lot of properties that look like this: public SomeObject SomeData { get { return _SomeData; } set { _SomeData = value; OnPropertyChanged("SomeData"); } } Of course, I have an appropriate overridden IDataErrorInfo.this[] in my class to do validation. Question: In a binding situation, when does the validation code get executed? When is the property set? When is the setter code executed? What if the validation fails? For example: User enters new data. Binding writes data to property. Property set method is executed. Binding checks this[] for validation. If the data is invalid, the binding sets the property back to the old value. Property set method is executed again. This is important if you are adding "hooks" into the set method, like: public string PathToFile { get { return _PathToFile; } set { if (_PathToFile != value && // prevent unnecessary actions OnPathToFileChanging(value)) // allow subclasses to do something or stop the setter { _PathToFile = value; OnPathToFileChanged(); // allow subclasses to do something afterwards OnPropertyChanged("PathToFile"); } } }

    Read the article

  • wpf observableCollection

    - by Asha
    I have an ObservableCollection which is dataContext for my treeview when I try to remove an Item from ObservableCollection I will get an error that Object reference not set to an instance of an object . can you please tell me why this error is happening and what is the solution thanks EDIT 1: The code is something like : class MyClass : INotifyPropertyChanged { //my class code here } public partial class UC_myUserControl : UserControl { private ObservableCollection<MyClass> myCollection = new ObservableCollection<MyClass>(); private void UserControl_Loaded(object sender, RoutedEventArgs e) { myCollection.add(new myClass); myTreeView.DataContext = myCollection ; } private void deleteItem() { myCollection.RemoveAt(0); //after removing I get error Which I guess should be something related //to interface update but I don't know how can I solve it } } Exception Detail : System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." Source="PresentationFramework" EDIT 3: I have a style which is for my treeitem to keep the treeitems expanded <Style TargetType="TreeViewItem"> <Setter Property="IsExpanded" Value="True" /> </Style> and with commenting this part I wont get any error !!! Now I want to change my question to why having this style is causing error ?

    Read the article

  • Silverlight dataGrid binding with ria Service doesn' work

    - by Abdulrhman
    hi every one i'm new to Silverlight and it's totally driving me crazy !! i'm using SL4 and trying to bind datagrid with a Domain Service Query: what i did exactly is i generate an ado.net entity model from my database, then create a domain Service class from this model. then in my page i put Datagrid & button. in the click event for this button i write this code: RRDomainContext rr = new RRDomainContext(); this.dataGrid1.ItemsSource = rr.Rooms; this.rr.Load(this.rr.GetRoomsQuery()); when this method executed the nothing changed at the datagrid. can anyone help me with this ?

    Read the article

  • Events doesn't fire when using UpdatePanel

    - by nitinkhanna
    Hi, What I did is, I have made 2 user controls. One control is inside the other. NoW one control has a buttton and a data grid and datalist in it. When pressing button I am filling datagrid while datalist visiblity false. This is working fine. But now when I press some link button in datalist data, it should call item_command event but it is not calling. I have also used a Updatepanel as a wrapper(all controls are inside it). Please suggest what may be the reason for that. Thanks

    Read the article

  • How can i bind parent's property to its child's property?

    - by walkor
    I have a GroupBox, which is defined like this <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Groupbox" > <Style TargetType="local:GroupBox"> <Setter Property="BorderBrush" Value="DarkGray"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="Padding" Value="6"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:GroupBox"> <Grid Background="{TemplateBinding Background}"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Border BorderThickness="{TemplateBinding BorderThickness}" Grid.Row="1" Grid.RowSpan="2" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3"> <Border.Clip> <GeometryGroup FillRule="EvenOdd"> <RectangleGeometry x:Name="FullRect" Rect="0,0,300,200"/> <RectangleGeometry x:Name="HeaderRect" Rect="6,0,100,100"/> </GeometryGroup> </Border.Clip> </Border> <ContentPresenter Grid.Row="2" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}"/> <ContentControl x:Name="HeaderContainer" Margin="6,0,0,0" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Left"> <ContentPresenter Margin="3,0,3,0" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}"/> </ContentControl> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> And i'm using this control like this <Controls:GroupBox x:Name="GroupBox"> <Controls:GroupBox.HeaderTemplate> <DataTemplate> <CheckBox "Header" x:Name="cbHeader"/> </DataTemplate> </Controls:GroupBox.HeaderTemplate> <Controls:GroupBox> So, well, my questions - how can i bind property IsEnabled of GroupBox to the Checkbox property IsChecked? Thanks in advance.

    Read the article

  • How to cause bindings to be updated, particularly for derived values?

    - by rrhartjr
    I'm using some CLR objects that use the INotifyPropertyChanged interface and use the PropertyChanged function to update in WPF bindings. Pretty boilerplate: protected void RaisePropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } Then the property: private double m_TotalWidgets = 0; public double TotalWidgets { get { return m_TotalWidgets; } set { m_TotalWidgets = value; RaisePropertyChanged("TotalWidgets"); } } Is there a better way to update a derived value or even the whole class? Say I had a calculated value: public double ScaledWidgets { get { return TotalWidgets * CONSTANT_FACTOR; } } I would have to fire ScaledWidget's PropertyChanged when TotalWidgets is updated, eg: set { m_TotalWidgets = value; RaisePropertyChanged("TotalWidgets"); RaisePropertyChanged("ScaledWidgets"); } Is there a better way to do this? Is it possible "invalidate" the whole object, especially if there are a lot of derived values? I think it would be kind of lame to fire 100 PropertyChanged events.

    Read the article

  • Binding ComboBoxes to enums... in Silverlight!

    - by Domenic
    So, the web, and StackOverflow, have plenty of nice answers for how to bind a combobox to an enum property in WPF. But Silverlight is missing all of the features that make this possible :(. For example: You can't use a generic EnumDisplayer-style IValueConverter that accepts a type parameter, since Silverlight doesn't support x:Type. You can't use ObjectDataProvider, like in this approach, since it doesn't exist in Silverlight. You can't use a custom markup extension like in the comments on the link from #2, since markup extensions don't exist in Silverlight. You can't do a version of #1 using generics instead of Type properties of the object, since generics aren't supported in XAML (and the hacks to make them work all depend on markup extensions, not supported in Silverlight). Massive fail! As I see it, the only way to make this work is to either Cheat and bind to a string property in my ViewModel, whose setter/getter does the conversion, loading values into the ComboBox using code-behind in the View. Make a custom IValueConverter for every enum I want to bind to. Are there any alternatives that are more generic, i.e. don't involve writing the same code over and over for every enum I want? I suppose I could do solution #2 using a generic class accepting the enum as a type parameter, and then create new classes for every enum I want that are simply class MyEnumConverter : GenericEnumConverter<MyEnum> {} What are your thoughts, guys?

    Read the article

  • ComboBox SelectedItem vs SelectedValue

    - by Anna Lear
    The following code works as you’d expect — MyProperty on the model is updated when the user picks a new item in the dropdown. comboBox1.DataBindings.Add("SelectedValue", myModel, "MyProperty", true, DataSourceUpdateMode.OnPropertyChanged); The following, however, doesn’t work the same way and the model update isn’t triggered until the input focus moves to another control on the form: comboBox1.DataBindings.Add("SelectedItem", myModel, "MyProperty", true, DataSourceUpdateMode.OnPropertyChanged); Does anybody know why? I don’t even know where to start investigating the cause. Pointers in the right direction to start the investigation or an outright explanation would be equally appreciated. Thanks.

    Read the article

  • WPF ComboBox drop-down (data bound) values not changing

    - by Jefim
    I bind the ItemsSource of a ComboBox to an ObservableCollection<MyClass>. In code I change the collection (e.g. edit the MyClass.Name property). The problem: the change is not reflected in the dropdown box if the ComboBox, yet when I seled the item from the dropdown it is displayed correctly in the selected item box of the ComboBox. What's going on? :) PS MyClass has INotifyPropertyChanged implemented

    Read the article

  • How to bind a complex dictionary to a Gridview in asp.net?

    - by Mehdi
    I've used an early binding of a dictionary<string, string> to a gridview to show Urls Text and its HRef as key-value and it works like a charm. But since I want to replace the dictionary with this one : dictionary<string, LinkInfo> the binding goes wrong! Should I handle some events like as onItemDataBound or something? and the LinkInfo structure is: public struct LinkInfo{ public string href; public bool Enabled; }

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >