hans

hans

  • NA
  • 4
  • 3.7k

little easy question to listbox

Jun 15 2013 11:46 PM
hi, my windows phone emulator show my only the path of my local database !? i want to see content. big thanks for your helps .









----------------------------Main page
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 Microsoft.Phone.Controls;

namespace Spielleiter_App_03
{
    public partial class Erstellen_Uebersicht : PhoneApplicationPage
    {

        private const string strConnectionString = @"isostore:/StudentDB.sdf";

        public Erstellen_Uebersicht()
        {
            InitializeComponent();

            using (Hauptklasse context = new Hauptklasse(strConnectionString))
            {
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                }
            }
            using (Hauptklasse DB = new Hauptklasse(strConnectionString))
            {
                var a = from b in DB.GetTable<Tabelle_Veranstaltung>() select b.Extra;
                //lstContactname.ItemsSource = a;
                List<Tabelle_Veranstaltung> dataSource = new List<Tabelle_Veranstaltung>();
                foreach (var x in a)
                {
                    dataSource.Add(new Tabelle_Veranstaltung() { Extra = x });

                }

                this.myListBox.ItemsSource = dataSource;
                if (myListBox.Items.Count == 0)
                {
                    myListBox.Visibility = Visibility.Collapsed;

                }
                else
                {
                    myListBox.Visibility = Visibility.Visible;

                }

            }
        }

        private void myButton_Einmalige_Veranstaltung_Erstellen_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/Erstellen_Button_Einmalige_Veranstaltung.xaml", UriKind.Relative));
        }
    }
}
----------------------------------second page
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 Microsoft.Phone.Controls;

namespace Spielleiter_App_03
{
    public partial class Erstellen_Button_Einmalige_Veranstaltung : PhoneApplicationPage
    {
        private const string strConnectionString = @"isostore:/StudentDB.sdf";
        public string parameterValue;
        public string Action;
        public string id;

        public Erstellen_Button_Einmalige_Veranstaltung()
        {
            InitializeComponent();

            using (Hauptklasse context = new Hauptklasse(strConnectionString))
            {
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                }
            }
        }

        private void myButton_erstellen_Click(object sender, RoutedEventArgs e)
        {
            using (Hauptklasse DB = new Hauptklasse(strConnectionString))
            {
                Tabelle_Veranstaltung newVeranstaltung = new Tabelle_Veranstaltung
                {
                    //Id = txtfname.Text.ToString() + " " + txtlastName.Text.ToString(),
                    Extra = myTextBox_Name.Text.ToString() + " " + textBox1.Text.ToString(),
                    Name = myTextBox_Name.Text.ToString(),
                    Typ = textBox1.Text.ToString(),
                    //Mobile = txtMobile.Text.ToString(),
                    //Telephone = txtTelephone.Text.ToString(),
                    //Email = txtEmail.Text.ToString()

                };
                DB.Veranstaltungen_H.InsertOnSubmit(newVeranstaltung);
                DB.SubmitChanges();
               

            }

            myTextBox_Name.Text = "";
            //txtlastName.Text = "";
            //txtMobile.Text = "";
            //txtTelephone.Text = "";
            //txtEmail.Text = "";
            this.NavigationService.Navigate(new Uri("/Erstellen_Uebersicht.xaml", UriKind.Relative));
        }
    }
}
---------------------------[table]
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq.Mapping;
using System.Data.Linq;
namespace Spielleiter_App_03
{
    [Table]

    public class Tabelle_Veranstaltung
    {
        [Column(Storage = "Id", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public string Id
        {
            get;
            set;
        }
        [Column(CanBeNull = true)]
        public string Extra
        {
            get;
            set;
        }

        [Column(CanBeNull = true)]
        public string Name
        {
            get;
            set;
        }
        [Column(CanBeNull = true)]
        public string Typ
        {
            get;
            set;
        }

      

    }
}
----------------------------------[class]
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq;


namespace Spielleiter_App_03
{
    public class Hauptklasse : DataContext
    {
        public Hauptklasse(string connectionString) : base(connectionString)
        {
        }
         public Table<Tabelle_Veranstaltung> Veranstaltungen_H
         {
            get
            {
                 return this.GetTable<Tabelle_Veranstaltung>();
            }
        }
    }
}
---------------------------------------

Answers (2)