Search Results

Search found 10 results on 1 pages for 'dataitems'.

Page 1/1 | 1 

  • If statement with dataitems in markup

    - by Eric
    I am trying to write an if statement to decide whether or not to display a field. I'm using a listview. <telerik:RadListView ID="RadListView4" runat="server" ItemPlaceholderID="WitnessPlaceHolder" DataSourceID="SqlDataSource5"> <LayoutTemplate> <asp:PlaceHolder ID="WitnessPlaceHolder" runat="server" /> </LayoutTemplate> <ItemTemplate> <center> <fieldset style="float: left; width: 280px;"> <legend> <%# Eval("title").ToString()%> </legend> <table> <tr> <td align="center"> <%if (DataBinder.Eval(Container.DataItem,"field").Equals("C")) Response.Write(Eval("field"));%> </td> How can I write the above if statement in the markup?? What i have doesn't work.

    Read the article

  • Populate datagrid using Datacontext in C# WPF

    - by anon
    I'm trying to get data from file. The file first has three lines of text that describes the file, then there is a header for the data below. I've managed to extract that. What I'm having problems is getting the data below the header line. The data below the header line can look like "1 2 3 4 5 6 7 8 9 abc". DataGrid dataGrid1 = new DataGrid(); masterGrid.Children.Add(dataGrid1); using (TextReader tr = new StreamReader(@filename)) { int lineCount = 1; while (tr.Peek() >= 0) { string line = tr.ReadLine(); { string[] data = line.Trim().Split(' '); Dictionary<string, object> sensorData = new Dictionary<string, object>(); for (int i = 0, j = 0; i < data.Length; i++) { //I know that I'm delimiting the data by a space before. //but the data from the text file doesn't necessarily have //just one space between each piece of data //so if I don't do this, spaces will become part of the data. if (String.Compare(data[i]," ") > 0) { sensorData[head[j]] = data[i]; j++; } } sensorDatas.Add(sensorData); sensorData = null; } lineCount++; } } dataGrid1.DataContext = sensorDatas; I can't figure out why this doens't work. If I change "dataGrid1.DataContext = sensorDatas;" to "dataGrid1.ItemsSource = sensorDatas;" then I get the data in the proper columns, but I also get some Raw View data such as: Comparer, Count, Keys, Values as columns, which I don't want. Any insight?

    Read the article

  • Why does this C# event handler not respond to this event in this Silverlight application?

    - by Edward Tanguay
    Can anyone tell me why the following code successfully executes this event: OnLoadingComplete(this, null); but never executes this event handler? void initialDataLoader_OnLoadingComplete(object obj, DataLoaderArgs args) CODE: using System; using System.Collections.Generic; using System.Linq; using System.Windows.Controls; using System.Diagnostics; namespace TestEvent22928 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); DataLoader initialDataLoader = new DataLoader("initial"); initialDataLoader.RegisterText("test1", "http://test:111/testdata/test1.txt"); initialDataLoader.RegisterText("test2", "http://test:111/testdata/test2.txt"); initialDataLoader.BeginLoading(); initialDataLoader.OnLoadingComplete += new DataLoader.LoadingComplete(initialDataLoader_OnLoadingComplete); } void initialDataLoader_OnLoadingComplete(object obj, DataLoaderArgs args) { Debug.WriteLine("loading complete"); //WHY DOES EXECUTION NEVER GET HERE? } } public class DataManager { public DataLoader CreateDataloader(string dataloaderIdCode) { DataLoader dataLoader = new DataLoader(dataloaderIdCode); return dataLoader; } } public class DataLoader { public string IdCode { get; set; } public List<DataItem> DataItems { get; set; } public delegate void LoadingComplete(object obj, DataLoaderArgs args); public event LoadingComplete OnLoadingComplete = delegate { }; private int dataItemCurrentlyLoadingIndex; public DataLoader(string idCode) { IdCode = idCode; DataItems = new List<DataItem>(); dataItemCurrentlyLoadingIndex = -1; } public void RegisterText(string idCode, string absoluteSourceUrl) { DataItem dataItem = new DataItem { IdCode = idCode, AbsoluteSourceUrl = absoluteSourceUrl, Kind = DataItemKind.Text }; DataItems.Add(dataItem); } public void BeginLoading() { LoadNext(); } private void LoadNext() { dataItemCurrentlyLoadingIndex++; if (dataItemCurrentlyLoadingIndex < DataItems.Count()) { DataItem dataItem = DataItems[dataItemCurrentlyLoadingIndex]; Debug.WriteLine("loading " + dataItem.IdCode + "..."); LoadNext(); } else { OnLoadingComplete(this, null); //EXECUTION GETS HERE } } } public class DataItem { public string IdCode { get; set; } public string AbsoluteSourceUrl { get; set; } public DataItemKind Kind { get; set; } public object DataObject { get; set; } } public enum DataItemKind { Text, Image } public class DataLoaderArgs : EventArgs { public string Message { get; set; } public DataItem DataItem { get; set; } public DataLoaderArgs(string message, DataItem dataItem) { Message = message; DataItem = dataItem; } } }

    Read the article

  • high performance hibernate insert

    - by luke
    I am working on a latency sensitive part of an application, basically i will receive a network event transform the data and then insert all the data into the DB. After profiling i see that basically all my time is spent trying to save the data. here is the code private void insertAllData(Collection<Data> dataItems) { long start_time = System.currentTimeMillis(); long save_time = 0; long commit_time = 0; Transaction tx = null; try { Session s = HibernateSessionFactory.getSession(); s.setCacheMode(CacheMode.IGNORE); s.setFlushMode(FlushMode.NEVER); tx = s.beginTransaction(); for(Data data : dataItems) { s.saveOrUpdate(data); } save_time = System.currentTimeMillis(); tx.commit(); s.flush(); s.clear(); } catch(HibernateException ex) { if(tx != null) tx.rollback(); } commit_time = System.currentTimeMillis(); System.out.println("Save: " + (save_time - start_time)); System.out.println("Commit: " + (commit_time - save_time)); System.out.println(); } The size of the collection is always less than 20. here is the timing data that i see: Save: 27 Commit: 9 Save: 27 Commit: 9 Save: 26 Commit: 9 Save: 36 Commit: 9 Save: 44 Commit: 0 This is confusing to me. I figure that the save should be quick and all the time should be spent on commit. but clearly I'm wrong. I have also tried removing the transaction (its not really necessary) but i saw worse times... I have set hibernate.jdbc.batch_size=20... i need this operation to be as fast as possible, ideally there would only be one roundtrip to the database. How can i do this?

    Read the article

  • How to bind WPF TreeView to a List<Drink> programmatically?

    - by Joan Venge
    So I am very new to WPF and trying to bind or assign a list of Drink values to a wpf treeview, but don't know how to do that, and find it really hard to find anything online that just shows stuff without using xaml. struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Drink ( string name, int popularity ) : this ( ) { this.Name = name; this.Popularity = popularity; } } List<Drink> coldDrinks = new List<Drink> ( ){ new Drink ( "Water", 1 ), new Drink ( "Fanta", 2 ), new Drink ( "Sprite", 3 ), new Drink ( "Coke", 4 ), new Drink ( "Milk", 5 ) }; } } How can I do this in code? For example: treeview1.DataItems = coldDrinks; and everything shows up in the treeview.

    Read the article

  • Binding to an XElement

    - by twreid
    I need help binding to an XElement. Basically I am making a editor for certain elements in a web.config and I extract them as XElements and my View binds to a Collection of DataItems which has a property that contains my XElement. When I do Text="{Binding Path=Data, Mode=OneWay, NotifyOnSourceUpdated=True}"/> I get all the text of the Element, but If I try Text="{Binding Path=Data.Elements[], Mode=OneWay, NotifyOnSourceUpdated=True}"/> It doesn't work the TextBox is empty. I am trying to find a way to Template different sections dynamically to make them easier to edit instead of editing raw XMl.

    Read the article

  • Stackpanel add item animation

    - by grzegorz_p
    Hello, I've been struggling a while with marquee-style image scrolling control. At a moment, I stuck up with templated ItemsControl: <Window.Resources> <DataTemplate x:Key="itemsTemplate"> <Image Source="{Binding AbsolutePath}"></Image> </DataTemplate> </Window.Resources> <ItemsControl ItemTemplate="{StaticResource itemsTemplate}" x:Name="ic" ItemsSource="{Binding ElementName=mainWindow, Path=DataItems}" VirtualizingStackPanel.IsVirtualizing="True"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Vertical" VerticalAlignment="Bottom" VirtualizingStackPanel.IsVirtualizing="True" > </VirtualizingStackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> ItemsControl is bound to ObservableCollection, so I can add items at runtime. As soon as item goes off-screen it's removed from ObservableCollection. The last thing to do is implementing custom item add behavior (smooth slide-in instead of insert-translateothers behavior). Shall I derive from StackPanel to achieve such effect or just perform DoubleAnimation on currently adding item? Any suggestions appreciated.

    Read the article

  • validation control unable to find its control to validate

    - by nat
    i have a repeater that is bound to a number of custom dataitems/types on the itemdatabound event for the repeater the code calls a renderedit function that depending on the custom datatype will render a custom control. it will also (if validation flag is set) render a validation control for the appropriate rendered edit control the edit control overrides the CreateChildControls() method for the custom control adding a number of literalControls thus protected override void CreateChildControls() { //other bits removed - but it is this 'hidden' control i am trying to validate this.Controls.Add(new LiteralControl(string.Format( "<input type=\"text\" name=\"{0}\" id=\"{0}\" value=\"{1}\" style=\"display:none;\" \">" , this.UniqueID , this.MediaId.ToString()) )); //some other bits removed } the validation control is rendered like this: where the passed in editcontrol is the control instance of which the above createchildcontrols is a method of.. public override Control RenderValidationControl(Control editControl) { Control ctrl = new PlaceHolder(); RequiredFieldValidator req = new RequiredFieldValidator(); req.ID = editControl.ClientID + "_validator"; req.ControlToValidate = editControl.UniqueID; req.Display = ValidatorDisplay.Dynamic; req.InitialValue = "0"; req.ErrorMessage = this.Caption + " cannot be blank"; ctrl.Controls.Add(req); return ctrl; } the problem is, altho the validation controls .ControlToValidate property is set to the uniqueid of the editcontrol. when i hit the page i get the following error: Unable to find control id 'FieldRepeater$ctl01$ctl00' referenced by the 'ControlToValidate' property of 'FieldRepeater_ctl01_ctl00_validator'. i have tried changing the literal in the createchildcontrols to a new TextBox(), and then set the id etc then, but i get a similar problem. can anyone enlighten me? is this because of the order the controls are rendered in? ie the validation control is written before the editcontrol? or... anyhow any help much appreciated thanks nat

    Read the article

  • Wpf ItemsControl with datatemplate, problem with doubled border for some items

    - by ksirg
    Hi, I have simple ItemsControl with custom datatemplate, template contains only textblock with border. All items should be displayed vericaly one after another, but some items have extra border. How can I remove it? I want to achieve something similar to enso launcher, it looks like My implementation looks like this here is my xaml code: <Window x:Class="winmole.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" x:Name="hostWindow" Height="Auto" MinHeight="100" MinWidth="100" Width="Auto" Padding="10" AllowsTransparency="True" WindowStyle="None" Background="Transparent" Top="0" Left="0" SizeToContent="WidthAndHeight" Topmost="True" Loaded="Window_Loaded" KeyUp="Window_KeyUp" > <Window.Resources> <!--Simple data template for Items--> <DataTemplate x:Key="itemsTemplate"> <Border Background="Black" Opacity="0.9" HorizontalAlignment="Left" CornerRadius="0,2,2,0"> <TextBlock Text="{Binding Path=Title}" TextWrapping="Wrap" FontFamily="Georgia" FontSize="30" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Stretch" TextAlignment="Left" Padding="5" Margin="0" Foreground="Yellow"/> </Border> </DataTemplate> </Window.Resources> <DockPanel> <ItemsControl DockPanel.Dock="Bottom" Name="itcPrompt" ItemsSource="{Binding ElementName=hostWindow, Path=DataItems}" ItemTemplate="{StaticResource itemsTemplate}" > <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DockPanel>

    Read the article

  • Expanders inside listbox leaving blank space on collapse

    - by siz
    We have a rather complex UI that is presenting some problems for us. I have a ListBox that contains a set of DataItems. The DataTemplate for each item is an Expander. The header is text, the content of the Expander is a ListBox. The ListBox contains SubDataItems. The DataTemplate for each SubDataItem is an Expander. Here is a simplified XAML in which I reproduce the issue: <ListBox ItemsSource="{Binding Items}"> <ListBox.ItemTemplate> <DataTemplate> <Expander Header="{Binding Header}"> <ListBox ItemsSource="{Binding SubItems}"> <ListBox.ItemTemplate> <DataTemplate> <Expander Header="{Binding SubHeader}"> <Grid Height="40"> <TextBlock Text="{Binding SubText}" /> </Grid> </Expander> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Expander> </DataTemplate> </ListBox.ItemTemplate> </ListBox> There is a problem with how the layout is produced. If any Expander corresponding to the SubDataItem is expanded, the ListBoxItem containing this ListBox (the Expander.Content in the parent DataTemplate) correctly requests more space. So I can expand all SubDataItems and correctly see my data. However, when I collapse, the space I previously asked to expand, remains blank, instead of being reclaimed by the ListBoxItem. This is a problem because if I have say 10 SubDataItems and happen to expand all of them at the same time and then collapse, there is a significant amount of white space wasting my real estate. How can I force WPF to resize the ListBoxItem to the correct state?

    Read the article

1