Click here to Skip to main content
15,911,789 members

Comments by Member 11143298 (Top 7 by date)

Member 11143298 29-Oct-14 0:32am View    
alright sorry to bother you....please you can help me.
Member 11143298 29-Oct-14 0:10am View    
Thanks for your concern but i have done the same thing setup the executable project as the startup project btu it throws an activation exception.....Please let me out of this...thanks in advance
Member 11143298 28-Oct-14 23:42pm View    
Deleted
In my file ViewModels.MainViewModel.cs the source Code as
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Configuration;
using System.ComponentModel;
using System.Collections.ObjectModel;
using MVVM_DemoAppl.Models;
using System.Data;


namespace MVVM_DemoAppl.ViewModels
{



public class MainViewModel : INotifyPropertyChanged
{
Model _myModel = new Model();
private ObservableCollection<Person> _empdata = new ObservableCollection<Person>();
private ObservableCollection<Person> Empdata
{
get { return _empdata; }
set
{
_empdata = value;
OnPropertyChanged("EmployeeTable");
}
}
public MainViewModel()
{
initializeload();
}
private void initializeload()
{
DataTable table = _myModel.getData();


for (int i = 0; i < table.Rows.Count; ++i)
Empdata.Add(new Person
{
Names = table.Rows[i][0].ToString(),
Age = Convert.ToInt32(table.Rows[i][1]),
Description = table.Rows[i][2].ToString(),
});

}

public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyname)
{
var handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyname));
}
}

public class Model
{

public DataTable getData()
{
DataTable ndt = new DataTable();
SqlConnection sqlcon = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=WINJIT332\SQL2012
");
sqlcon.Open();
SqlDataAdapter da = new SqlDataAdapter("Select * from EmployeeTable", sqlcon);
da.Fill(ndt);
return ndt;

}





}

}






and Models as Person.cs...

in app.xaml.cs i have the code as
base.OnStartup(e);
var mainWindow = new MainWindow();
var viewModel = new MainViewModel();
mainWindow.DataContext = viewModel;
mainWindow.Show();

btu still i could not get the Table of my SQL named EmployeeTable on dataGrid Control....can anybody help me with this Problem
Member 11143298 28-Oct-14 9:21am View    
Yes you are right I went for tutorials but cold not get where to code for Views,Models and ViewModels...I shall be highly obliged if you shall do the needful. Thanks in advance.
Member 11143298 28-Oct-14 9:19am View    
Would you care to give me any kind of examples or any thing through which i could understand the concepts. I have tried with simple MVVM but not well verse with Prism.
Your help would be highly appreciable.