views:

925

answers:

1

Hi,

I created crystal report and through Data-->object i generated the DataSource and i added the fields from generated Datasource. My problem is, how to assign the values to the datasource.

Is anything like grid.DataSource = MyCustomClass is available. I can't access the Database directly [its a remove service]. What is the way to assign the values.

I want some thing like

    class CustomClass
    {
      string name;  
      string number;

       public string Name
       {
       set
       {
         return name;
       }
       }

       public string Number
       {
       set
       {
           return number;
        }
       }

    }
CustomClass custom = new CustomClass ();

custom.Name = "Mohan";
custom.Number = "100";

reportViewer.DataSource = custom ;

Is it anything similar to this is available.

+2  A: 

Take a look at this link:

http://msdn.microsoft.com/en-us/library/ms227595(VS.80).aspx

It will show you how this can be done. You can view my answer on this question for an example. http://stackoverflow.com/questions/1140229/how-to-use-crystal-reports-without-a-tightly-linked-db-connection/1157001#1157001

The quick explanation for this is that you should be able to add your custom object into an ArrayList and then use the ArrayList as the datasource. Hope this helps.

Dusty
+1 lol all the newbs must not see the upvote arrow?
dotjoe