Newbie: Assigning a new Dataset at runtime

  • Thread starter Thread starter Paul Ericksen
  • Start date Start date
P

Paul Ericksen

I am new to C#, but have 9 years of professional programming experience.

As an exercise, I made a webservice which spits out a DataSet. The client
gets it and loads it into a grid. All works very slick. I was creating a new
DataSet in code

ProjectX.SessionList px = new ProjectX.SessionList();DataSet dsl =
px.GetSessions();

dataGrid1.DataSource = dsl;//dataSet1;//

dataGrid1.DataMember = "Sessions";
 
Oops, I hit Ctrl+Enter rather than Shift+Enter and it sent :O

ProjectX.SessionList px = new ProjectX.SessionList();
DataSet dsl = px.GetSessions();
dataGrid1.DataSource = dsl;
dataGrid1.DataMember = "Sessions";

so this code correctly fills the grid.

When I did this (where dataSet1 is a placed DataSet component):
ProjectX.SessionList px = new ProjectX.SessionList();
dataSet1 = px.GetSessions();
dataGrid1.DataSource = dataSet1;
dataGrid1.DataMember = "Sessions";

Is this the right way to do it? To assign the result of the webservice call
px.GetSessions() (which returns a DataSet) directly to the dataSet1?

It works, but is that the proper way to do it?

TIA,
Paul
 
Back
Top