This is a migrated thread and some comments may be shown as answers.

New to WPF/DataBinding

1 Answer 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
bradley baker
Top achievements
Rank 1
bradley baker asked on 21 Jan 2010, 10:02 PM
How do I bind a GridView to a dataset, is it even possible?  I looked iin the guide book and they all seem to binding via the code and in the ASP.NET version you can just link it to the SQL datasouce you created.  (Again dont know much of this WPF world)

Im use to the ASP.NET RadGrid and binding options but Im trying to see if I can get one of my larger applications to run in WPF.

Im using Q3 WPF and VB.  I added a DataSet and have the query I want in it.  (I just left it the default "DataSet1.xsd" with all the default values for testing.)

1 Answer, 1 is accepted

Sort by
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 22 Jan 2010, 02:41 AM
Hello Bradly,
     Here's how I execute a proc from WPF and attach the dataset to the grid (I am connecting to a Sybase ASE database):

private DataSet statusDataSet;

public DataSet StatusDataSetRef
{
  get { return statusDataSet; }
  set { statusDataSet = value; }
}

AseDataAdapter aseadpt = new AseDataAdapter();
AseParameter inParam;

StatusDataSetRef = new DataSet();
            
using (AseCommand cmd = new AseCommand("<procedure name>", sybconnection))
{
   cmd.CommandType = CommandType.StoredProcedure;

   inParam = new AseParameter("@p_userid", AseDbType.VarChar, 7);
   inParam.Direction = ParameterDirection.Input;
   inParam.Value = sybcon.UserID;
   cmd.Parameters.Add(inParam);

   try
   {
    aseadpt.SelectCommand = cmd;
    aseadpt.Fill(StatusDataSetRef);
    gridname.ItemsSource = StatusDataSetRef;
   }
   catch (AseException ex)
   {
     MessageBox.Show(ex.Source + " : " + ex.Message + " (" + ex.ToString() + ")", "Execute Stored Precedure failed.");
   }
}
Tags
GridView
Asked by
bradley baker
Top achievements
Rank 1
Answers by
Jorge Gonzalez
Top achievements
Rank 1
Share this question
or