Silverlight / WPF - WPF and Dataset xsd,xsc,xss?

Asked By Kannabiran .
22-Aug-08 09:03 AM

HI,

   Im using wpf for designing purpose,i have to use dataset in my project, but im new to this one.i dont know how to use.i added dataset to my project by soln explorer--> add newitem-->Dataset. but i dont know whats the purpose of this one and i dont know how to use this one.. and also i need to know is it possible to store the values?.. could any one assist me??

regrds

Kanna..

hi  hi

22-Aug-08 09:08 AM

 following is the code snippet for adding DataRow into the Dataset.

ExampleRow = myDataTable.NewRow();
ExampleRow["Name"] = "testname";
ExampleRow["Age"] = 25;
myDataTable.Rows.Add(ExampleRow);

Go through these article hope they help you:

http://aspalliance.com/856_Working_with_DataSet_Objects_and_XML

http://msdn.microsoft.com/en-us/library/ss7fbaez.aspx

http://www.codeproject.com/KB/cpp/dataset.aspx

http://www.codersource.net/dataset_dot_net.html

See this info and code  See this info and code

22-Aug-08 09:10 AM

which will tell you how to bind dataset with list view with WPF,

This blog entry demonstrates the fundamentals of binding a WPF TreeView to a DataSet with two related DataTables. The technique presented herein could easily be extended to fit more sophisticated requirements, such as binding to more than two tables.

Many applications need to display hierarchical data in a TreeView, and often that data is retrieved from a database. In many situations the developer just needs to bind the TreeView directly to the DataSet which was populated with database data; creating custom domain objects and collections of those objects can be overkill sometimes. If you are currently in that situation, rest assured that it is actually fairly trivial to do this in WPF. :)

The basic gist of the solution is to bind the top level of TreeViewItems against the master DataTable, and then bind against DataRelations for any descendants of the root nodes. You need to use a HierarchicalDataTemplate for every non-leaf level of nodes, in other words, only the very lowest DataTable in the hierarchy is displayed with a non-hierarchical DataTemplate.

Let’s just get right into an example. Here is a method in a class called DataSetCreator which creates a DataSet with two related DataTables:

Creating a hierarchical DataSet

The resultant DataSet has two DataTables (‘Master’ and ‘Detail’) and one DataRelation (‘Master2Detail’). We want a TreeView to display the Master rows as top-level nodes and the Detail rows as children of their respective parent node. Here is the XAML for a Window which contains a TreeView configured to load and display that data:

Binding a TreeView to a DataSet

If you had, say, three related tables (Master –> Detail –> DetailInfo) then you could have the ‘DetailTemplate’ be a HierarchicalDataTemplate whose ItemsSource was bound to the DataRelation between ‘Detail’ and ‘DetailInfo,’ and the ItemTemplate a DataTemplate which displays the pertinent information in that table.

When you run the demo application and expand the root nodes, the TreeView looks like this:

The bound TreeView

Also go thr these links for more details;

http://forums.msdn.microsoft.com/en-US/wpf/threads/

http://rrelyea.spaces.live.com/blog/cns!167AD7A5AB58D5FE!1833.entry

http://www.codeproject.com/KB/miscctrl/GridView_WPF.aspx

Best Luck!!!!!!!!!!!!!!!!!!
Sujit.

Re : WPF and Dataset xsd,xsc,xss?  Re : WPF and Dataset xsd,xsc,xss?

22-Aug-08 09:12 AM

private void Window_Loaded(object sender, RoutedEventArgs e)

{

    BindData();          

}

 

private void BindData()

{

    DataSet dtSet = new DataSet();

    using (connection = new SqlConnection(connectionString))

    {

        command = new SqlCommand(sql, connection);              

        SqlDataAdapter adapter = new SqlDataAdapter();          

        connection.Open();

        adapter.SelectCommand = command;

        adapter.Fill(dtSet, "Customers");

        listBox1.DataContext = dtSet;

     

    }

}

 

 

Refer this link, it expain Data Binding in WPF :

http://www.c-sharpcorner.com/UploadFile/mahesh/WPFDataBinding08012008233147PM/WPFDataBinding.aspx

thanx  thanx
22-Aug-08 09:13 AM

Hi,

Whether it is possible to store the value as permanent in that dataset and by later it can transferred to database..is it possible?

Thanx  Thanx
22-Aug-08 09:17 AM

Hi Binny,

      Im familiar in the server code dataset, for ex: Dataset ds=new Dataset(); im not asking about this dataset.. im adding through solution explorer dataset.. i want to know about that dataset??

Thanx  Thanx
22-Aug-08 09:23 AM

Hi Deepak,

      DataSet dtSet = new DataSet();

    using (connection = new SqlConnection(connectionString))

    {

        command = new SqlCommand(sql, connection);              

        SqlDataAdapter adapter = new SqlDataAdapter();          

        connection.Open();

        adapter.SelectCommand = command;

        adapter.Fill(dtSet, "Customers");

        listBox1.DataContext = dtSet;

     

    }

 

You are using this codefile Dataset to fill the value..then whats the purpose of that adding from solution explorer dataset?? actually whats the use of that one?and what are the advatages by using that?

See  See
23-Aug-08 03:47 AM

you can store a datset value as a global varialbe so that you can use it in all the form.

Or you can store it in class variable so that you can access it on other forms by creating an objct of that.

And the thing you are asking abt Dataset dragging as design time. I think its something same like you add dataset while coding bu using code;

Dataset ds=new Dataset();

You can use that datset for same purpose as this.

Best Luck!!!!!!!!!!!!!
Sujit.

Use this  Use this
25-Aug-08 12:32 AM

private void Window_Loaded(object sender, RoutedEventArgs e)

{

    BindData();          

}

 

private void BindData()

{

    DataSet dtSet = new DataSet();

    using (connection = new SqlConnection(connectionString))

    {

        command = new SqlCommand(sql, connection);              

        SqlDataAdapter adapter = new SqlDataAdapter();          

        connection.Open();

        adapter.SelectCommand = command;

        adapter.Fill(dtSet, "Customers");

        listBox1.DataContext = dtSet;

     

    }

}

 

 

Refer this link, it expain Data Binding in WPF :

http://www.c-sharpcorner.com/UploadFile/mahesh/WPFDataBinding08012008233147PM/WPFDataBinding.aspx

Try this...  Try this...
25-Aug-08 12:32 AM
following is the code snippet for adding DataRow into the Dataset.
ExampleRow = myDataTable.NewRow();
ExampleRow["Name"] = "testname";
ExampleRow["Age"] = 25;
myDataTable.Rows.Add(ExampleRow);

Go through these article hope they help you:

http://aspalliance.com/856_Working_with_DataSet_Objects_and_XML

http://msdn.microsoft.com/en-us/library/ss7fbaez.aspx

http://www.codeproject.com/KB/cpp/dataset.aspx

http://www.codersource.net/dataset_dot_net.html

WPF  WPF
25-Aug-08 12:32 AM

This blog entry demonstrates the fundamentals of binding a WPF TreeView to a DataSet with two related DataTables. The technique presented herein could easily be extended to fit more sophisticated requirements, such as binding to more than two tables.

Many applications need to display hierarchical data in a TreeView, and often that data is retrieved from a database. In many situations the developer just needs to bind the TreeView directly to the DataSet which was populated with database data; creating custom domain objects and collections of those objects can be overkill sometimes. If you are currently in that situation, rest assured that it is actually fairly trivial to do this in WPF. :)

The basic gist of the solution is to bind the top level of TreeViewItems against the master DataTable, and then bind against DataRelations for any descendants of the root nodes. You need to use a HierarchicalDataTemplate for every non-leaf level of nodes, in other words, only the very lowest DataTable in the hierarchy is displayed with a non-hierarchical DataTemplate.

Let’s just get right into an example. Here is a method in a class called DataSetCreator which creates a DataSet with two related DataTables:

Creating a hierarchical DataSet

The resultant DataSet has two DataTables (‘Master’ and ‘Detail’) and one DataRelation (‘Master2Detail’). We want a TreeView to display the Master rows as top-level nodes and the Detail rows as children of their respective parent node. Here is the XAML for a Window which contains a TreeView configured to load and display that data:

Binding a TreeView to a DataSet

If you had, say, three related tables (Master –> Detail –> DetailInfo) then you could have the ‘DetailTemplate’ be a HierarchicalDataTemplate whose ItemsSource was bound to the DataRelation between ‘Detail’ and ‘DetailInfo,’ and the ItemTemplate a DataTemplate which displays the pertinent information in that table.

When you run the demo application and expand the root nodes, the TreeView looks like this:

The bound TreeView

Also go thr these links for more details;

http://forums.msdn.microsoft.com/en-US/wpf/threads/

http://rrelyea.spaces.live.com/blog/cns!167AD7A5AB58D5FE!1833.entry

http://www.codeproject.com/KB/miscctrl/GridView_WPF.aspx

Create New Account
help
Show images when clicking button Silverlight / WPF hi. . i have 5 images. now i want to show the images one by this in silver-light. . need ur suggestions. . regards gopal.s private void btnDisplay_Click( object sender, RoutedEventArgs e) { string connString = @"Data Source = . \ SQLEXPRESS;AttachDbFilename = | DataDirectory | \ Database.mdf;Integrated Security = True;User Instance = True" ; SqlConnection conn = new SqlConnection (connString); SqlDataAdapter da = new SqlDataAdapter ( "Select images from pictures" , conn); DataTable dt = new DataTable (); da.Fill(dt); conn.Open(); / / display
Image Upload with WPF(C#) Silverlight / WPF Hello, I'm trying to do image upload using c#(WPF), where i want image); comm.ExecuteNonQuery(); MessageBox .Show( "Record Added" ); sqlCon.Close(); } Retrieve private void btnDisplay_Click( object sender, RoutedEventArgs e) { string connString = @"Data Source = . \ SQLEXPRESS;AttachDbFilename = | DataDirectory | \ Database.mdf;Integrated Security = True;User Instance = True" ; SqlConnection conn = new SqlConnection (connString); SqlDataAdapter da = new SqlDataAdapter ( "Select images from pictures" , conn); DataTable dt = new DataTable (); da.Fill(dt); conn.Open(); / / display
DoWorkEventHandler (test_position_DoWork); test_position. RunWorkerCompleted + = new RunWorkerCompletedEventHandler (test_position_RunWorkerCompleted); test_position. WorkerSupportsCancellation = true ; } private void Mediasource_Click ( object sender, RoutedEventArgs e) { if (!position. IsBusy ) position. RunWorkerAsync (); mediaElement1. Source = new Uri (tb_filename. Text ); mediaElement1. LoadedBehavior = System System . Windows . Controls . MediaState . Manual ; mediaElement1. ScrubbingEnabled = true ; mediaElement1. Play (); } private void stopbutton_Click( object sender, RoutedEventArgs e) { mediaElement1. Stop (); } private void Playbutton_Click ( object sender, RoutedEventArgs e) { scrip_index = 0 ; mediaElement1. Play (); mediaElement1. LoadedBehavior = System . Windows . Controls . MediaState . Manual ; mediaElement1. UnloadedBehavior = System Windows . Controls . MediaState . Manual ; mediaElement1. ScrubbingEnabled = true ; } private void pausebutton_Click( object sender, RoutedEventArgs e) { if (mediaElement1. CanPause ) { mediaElement1. Pause (); } } private void AddToListbutton_Click ( object sender, RoutedEventArgs e) { video_script temp_item = new video_script(); temp_item.filename = tb_filename. Text ; temp_item.start_time = TimeSpan . FromMilliseconds ( Convert . ToInt32 Text = mediaElement1. Position . ToString (); if (playing && !test_position. IsBusy ) test_position. RunWorkerAsync (); } private void testbutton_Click( object sender, RoutedEventArgs e) { if (mediaElement1. Source ! = new Uri (tb_filename. Text )) mediaElement1. Source = new Uri (tb_filename. Text ); mediaElement1 slider2. Value < slider1. Value ) slider1. Value = slider2. Value - 1 ; } #endregion private void start_script_Click( object sender, RoutedEventArgs e) { scrip_index = - 1 ; next_item(); } private void mediaElement1_MediaOpened( object sender, RoutedEventArgs e) { } } } hi, Try below steps for solution: Silverlight Mediaplayer 1.Create Database table with following
Binding data from sql server to silverlight grid Hi, Im very new to silverlight. How we can fetch data from sql server and binding to silverlight grid. . Please help me in this regard. Thanks. HI refer this example http: / / www.codeproject.com / KB / silverlight / Silverlight3_SQL_WCF.aspx HI here is the example The DataGrid image refer the link for details http: / / odetocode.com / code / 740.aspx Introduction Silverlight 3 is by far, the coolest technology for web programming! I’m so excited about Silverlight 3! I hope I can share some things with you here that will help you get up and running with Silverlight 3 and SQL Server Data bases. This article walks you through displaying data from an SQL Server Data base in a Silverlight 3 application. There are three technologies that will be used in this example, which are
SilverLight What is SilverLight, its concept, why to use it and how to use it What is Silverlight? Silverlight is a new cross-browser, cross-platform implementation of the .NET Framework for building and browsers, including Microsoft Internet Explorer, Mozilla Firefox, Apple Safari, Opera. The plugin required to run Silverlight is very small in size hence gets installed very quickly. It is combination of different platform that allows you to select tools and the programming language you want to use. Silverlight integrates seamlessly with your existing Javascript and ASP.NET AJAX code to complement functionality which you have already created. Silverlight aims to compete with Adobe Flash and the presentation components of Ajax . It also competes with Sun Microsystems' JavaFX, which was launched a few days after Silverlight. Currently there are 2 versions of Silverlight: Silverlight 1.0 : Silverlight 1.0 consists of