473,695 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

populating Crystal Reports from DataGrid data

I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.

I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?

How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how in CR
do I tell it that this resultingDataSe t is what it needs for the
report?

I found a snippet of code that may work as PART of the solution, but I
need a little direction.
Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
End Sub

Jul 21 '08 #1
8 3077
I already responded to this post last week.

...

Did you attempt my advice?


"Brock" <wa********@yah oo.comwrote in message
news:61******** *************** ***********@r66 g2000hsg.google groups.com...
>I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.

I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?

How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how in CR
do I tell it that this resultingDataSe t is what it needs for the
report?

I found a snippet of code that may work as PART of the solution, but I
need a little direction.
Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
End Sub

Jul 21 '08 #2
I tried to adapt your method, well I should say I got totally lost in
the process. Back to your reply, ad I do appreciate the help:

"I would go with the PUSH method of CR (crystal report) development.
And instead of worrying about the datagrid as the SOURCE, cache
(session?)
the dataset (or datatable possibly) and use it as the source for the
datagrid AND then the report."

I went into my report to use the CR DatabaseExpert and stumbled when
trying to decide what to put in for my datasource. My datasource for
the datagrid itself gets populated with this code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'lblWelcome.Tex t = "Hello " & Global.UserSecu rity.Fname.Trim &
" " & Global.UserSecu rity.Lname
Dim act As Action
Dim pos As Position
Dim empname As String
Dim lvi As ListItem
Dim Employee As Employee
Dim empcount As Integer
act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
m_department = pos.Department. Name
Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
Dim dt As New DataTable
Dim count As Integer = 0
For Each emp As Employee In emps
SetListViewItem (emp, dt, count)
count = count + 1
Next
dgEmployees.Dat aSource = dt
dgEmployees.Dat aBind()
End Sub
Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add( "Emp #")
dt.Columns.Add( "Last Name")
dt.Columns.Add( "First Name")
dt.Columns.Add( "Title")
End If
Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
Dim employee As DataRow = dt.NewRow
employee("Emp #") = dr.Key
employee("Last Name") = dr.LastName

employee("First Name") = dr.FirstName
employee("Title ") = EmpPos.WorkAgai nstInfo.Title
dt.Rows.Add(emp loyee)
End Sub 'SetListViewIte m

The immediate challenge is that the datasource I was given by the
powers that be was a precompiled DLL with stored procedures and
database connections made to an Oracle database. So I didn't know the
foggiest idea of how the above code could be adapted/used to provide
CR with its data needs. I thought it might be in this specific case
more manageable for this newbie to find a way of using the datagrid as
the CR source (not that I know how to approach that either). But I can
see the challenges with caching and viewstate in a more complex page
than what I'm doing.

So any clues would be great... thanks! Brockus
On Jul 21, 12:54*pm, "sloan" <sl...@ipass.ne twrote:
I already responded to this post last week.

..

Did you attempt my advice?

"Brock" <wade.br...@yah oo.comwrote in message

news:61******** *************** ***********@r66 g2000hsg.google groups.com...
I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.
I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?
How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how in CR
do I tell it that this resultingDataSe t is what it needs for the
report?
I found a snippet of code that may work as PART of the solution, but I
need a little direction.
* *Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
* * * *DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
* *End Sub- Hide quoted text -

- Show quoted text -
Jul 21 '08 #3


Ok, since you're in a web world...you gotta keep some stuff straight.

Your attempt to "re-get" the DataSource ~from~ the DataGrid after the page
is rendered is not a good strategy.
You also need to remember that once a page displays, alot of things you had
in the code behind are not there anymore, unless you specifically save them
somewhere.
(Like the Session as the usual suspect).
So I will outline something that I think is the correct approach.
On the page_load...... ..
Populate your source data (dataset) however you normally do this. I
will call this the model from now on.
Put the model in the Session object using a unique keyname.
Bind the model to the DataGrid you have on the page already.

You now have two things:
1. The original data inside the Session object.
2. A ~display~ of the original data on the user's browser.

The user makes changes.

Now you need to COLLECT the information the user changed by iterating
over all the rows in the datagrid, and pulling out the values.
Tip: Use a hidden object for those pieces of information you don't
want to display, but want to keep around.
Put this data into a new dataset (a new "model").
You can throw this into the Session object as well (if you want to) with
a DIFFERENT key name.

Optional:
Use the model(1) and the model(2) and create a massaged version of
the data.

Take the new model , and use the PUSH method to populate the Crystal
Report.

PS
You should be able to bind the datagrid aganst this object
Dim emps As Employees
without artificially converting it to a dataset/datatable. Have you tried
this yet?


"Brock" <wa********@yah oo.comwrote in message
news:84******** *************** ***********@m73 g2000hsh.google groups.com...
I tried to adapt your method, well I should say I got totally lost in
the process. Back to your reply, ad I do appreciate the help:

"I would go with the PUSH method of CR (crystal report) development.
And instead of worrying about the datagrid as the SOURCE, cache
(session?)
the dataset (or datatable possibly) and use it as the source for the
datagrid AND then the report."

I went into my report to use the CR DatabaseExpert and stumbled when
trying to decide what to put in for my datasource. My datasource for
the datagrid itself gets populated with this code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'lblWelcome.Tex t = "Hello " & Global.UserSecu rity.Fname.Trim &
" " & Global.UserSecu rity.Lname
Dim act As Action
Dim pos As Position
Dim empname As String
Dim lvi As ListItem
Dim Employee As Employee
Dim empcount As Integer
act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
m_department = pos.Department. Name
Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
Dim dt As New DataTable
Dim count As Integer = 0
For Each emp As Employee In emps
SetListViewItem (emp, dt, count)
count = count + 1
Next
dgEmployees.Dat aSource = dt
dgEmployees.Dat aBind()
End Sub
Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add( "Emp #")
dt.Columns.Add( "Last Name")
dt.Columns.Add( "First Name")
dt.Columns.Add( "Title")
End If
Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
Dim employee As DataRow = dt.NewRow
employee("Emp #") = dr.Key
employee("Last Name") = dr.LastName

employee("First Name") = dr.FirstName
employee("Title ") = EmpPos.WorkAgai nstInfo.Title
dt.Rows.Add(emp loyee)
End Sub 'SetListViewIte m

The immediate challenge is that the datasource I was given by the
powers that be was a precompiled DLL with stored procedures and
database connections made to an Oracle database. So I didn't know the
foggiest idea of how the above code could be adapted/used to provide
CR with its data needs. I thought it might be in this specific case
more manageable for this newbie to find a way of using the datagrid as
the CR source (not that I know how to approach that either). But I can
see the challenges with caching and viewstate in a more complex page
than what I'm doing.

So any clues would be great... thanks! Brockus
On Jul 21, 12:54 pm, "sloan" <sl...@ipass.ne twrote:
I already responded to this post last week.

..

Did you attempt my advice?

"Brock" <wade.br...@yah oo.comwrote in message

news:61******** *************** ***********@r66 g2000hsg.google groups.com...
I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.
I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?
How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how in CR
do I tell it that this resultingDataSe t is what it needs for the
report?
I found a snippet of code that may work as PART of the solution, but I
need a little direction.
Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
End Sub- Hide quoted text -

- Show quoted text -

Jul 21 '08 #4
My apologies, but I'm a real newbie on several key issues. One is how
to access the "Session" and again how to specify in CR itself what its
datasource is.

On Jul 21, 3:11*pm, "sloan" <sl...@ipass.ne twrote:
Ok, since you're in a web world...you gotta keep some stuff straight.

Your attempt to "re-get" the DataSource ~from~ the DataGrid after the page
is rendered is not a good strategy.

You also need to remember that once a page displays, alot of things you had
in the code behind are not there anymore, unless you specifically save them
somewhere.
(Like the Session as the usual suspect).

So I will outline something that I think is the correct approach.

On the page_load...... ..
* * Populate your source data (dataset) however you normally do this.*I
will call this the model from now on.
* * Put the model in the Session object using a unique keyname.
* * Bind the model to the DataGrid you have on the page already.

* *You now have two things:
* * * * 1. *The original data inside the Session object.
* * * * 2. *A ~display~ of the original data on the user's browser.

* * The user makes changes.

* * Now you need to COLLECT the information the user changed by iterating
over all the rows in the datagrid, and pulling out the values.
* * * * Tip: *Use a hidden object for those pieces of information you don't
want to display, but want to keep around.
* * Put this data into a new dataset (a new "model").
* * You can throw this into the Session object as well (if you want to) with
a DIFFERENT key name.

* * Optional:
* * * * * Use the model(1) and the model(2) and create a massaged version of
the data.

* * Take the new model , and use the PUSH method to populate the Crystal
Report.

PS
You should be able to bind the datagrid aganst this object
* *Dim emps As Employees
without artificially converting it to a dataset/datatable. *Have you tried
this yet?

"Brock" <wade.br...@yah oo.comwrote in message

news:84******** *************** ***********@m73 g2000hsh.google groups.com...
I tried to adapt your method, well I should say I got totally lost in
the process. Back to your reply, ad I do appreciate the help:

"I would go with the PUSH method of CR (crystal report) development.
And instead of worrying about the datagrid as the SOURCE, cache
(session?)
the dataset (or datatable possibly) and use it as the source for the
datagrid AND then the report."

I went into my report to use the CR DatabaseExpert and stumbled when
trying to decide what to put in for my datasource. My datasource for
the datagrid itself gets populated with this code:

* * Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
* * * * 'Put user code to initialize the page here
* * * * 'lblWelcome.Tex t = "Hello " & Global.UserSecu rity.Fname..Tri m &
" " & Global.UserSecu rity.Lname
* * * * Dim act As Action
* * * * Dim pos As Position
* * * * Dim empname As String
* * * * Dim lvi As ListItem
* * * * Dim Employee As Employee
* * * * Dim empcount As Integer
* * * * act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
* * * * pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
* * * * m_department = pos.Department. Name
* * * * Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
* * * * Dim dt As New DataTable
* * * * Dim count As Integer = 0
* * * * For Each emp As Employee In emps
* * * * * * SetListViewItem (emp, dt, count)
* * * * * * count = count + 1
* * * * Next
* * * * dgEmployees.Dat aSource = dt
* * * * dgEmployees.Dat aBind()
* * End Sub
* * Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
* * * * If count = 0 Then
* * * * * * dt.Columns.Add( "Emp #")
* * * * * * dt.Columns.Add( "Last Name")
* * * * * * dt.Columns.Add( "First Name")
* * * * * * dt.Columns.Add( "Title")
* * * * End If
* * * * Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
* * * * Dim employee As DataRow = dt.NewRow
* * * * employee("Emp #") = dr.Key
* * * * employee("Last Name") = dr.LastName

* * * * employee("First Name") = dr.FirstName
* * * * employee("Title ") = EmpPos.WorkAgai nstInfo.Title
* * * * dt.Rows.Add(emp loyee)
* * End Sub 'SetListViewIte m

The immediate challenge is that the datasource I was given by the
powers that be was a precompiled DLL with stored procedures and
database connections made to an Oracle database. So I didn't know the
foggiest idea of how the above code could be adapted/used to provide
CR with its data needs. I thought it might be in this specific case
more manageable for this newbie to find a way of using the datagrid as
the CR source (not that I know how to approach that either). But I can
see the challenges with caching and viewstate in a more complex page
than what I'm doing.

So any clues would be great... thanks! * * Brockus

On Jul 21, 12:54 pm, "sloan" <sl...@ipass.ne twrote:
I already responded to this post last week.
..
Did you attempt my advice?
"Brock" <wade.br...@yah oo.comwrote in message
news:61******** *************** ***********@r66 g2000hsg.google groups.com....
>I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.
I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?
How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how in CR
do I tell it that this resultingDataSe t is what it needs for the
report?
I found a snippet of code that may work as PART of the solution, but I
need a little direction.
Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
End Sub- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
Jul 21 '08 #5

Session:
http://www.aspfree.com/c/a/ASP.NET/A...ts-in-ASP.NET/

Session belongs to Asp.Net, not CR.

...........

This is where you can store an object for later retrieval ( after a page
displays ).


"Brock" <wa********@yah oo.comwrote in message
news:fb******** *************** ***********@c58 g2000hsc.google groups.com...
My apologies, but I'm a real newbie on several key issues. One is how
to access the "Session" and again how to specify in CR itself what its
datasource is.

On Jul 21, 3:11 pm, "sloan" <sl...@ipass.ne twrote:
Ok, since you're in a web world...you gotta keep some stuff straight.

Your attempt to "re-get" the DataSource ~from~ the DataGrid after the page
is rendered is not a good strategy.

You also need to remember that once a page displays, alot of things you
had
in the code behind are not there anymore, unless you specifically save
them
somewhere.
(Like the Session as the usual suspect).

So I will outline something that I think is the correct approach.

On the page_load...... ..
Populate your source data (dataset) however you normally do this. I
will call this the model from now on.
Put the model in the Session object using a unique keyname.
Bind the model to the DataGrid you have on the page already.

You now have two things:
1. The original data inside the Session object.
2. A ~display~ of the original data on the user's browser.

The user makes changes.

Now you need to COLLECT the information the user changed by iterating
over all the rows in the datagrid, and pulling out the values.
Tip: Use a hidden object for those pieces of information you don't
want to display, but want to keep around.
Put this data into a new dataset (a new "model").
You can throw this into the Session object as well (if you want to) with
a DIFFERENT key name.

Optional:
Use the model(1) and the model(2) and create a massaged version of
the data.

Take the new model , and use the PUSH method to populate the Crystal
Report.

PS
You should be able to bind the datagrid aganst this object
Dim emps As Employees
without artificially converting it to a dataset/datatable. Have you tried
this yet?

"Brock" <wade.br...@yah oo.comwrote in message

news:84******** *************** ***********@m73 g2000hsh.google groups.com...
I tried to adapt your method, well I should say I got totally lost in
the process. Back to your reply, ad I do appreciate the help:

"I would go with the PUSH method of CR (crystal report) development.
And instead of worrying about the datagrid as the SOURCE, cache
(session?)
the dataset (or datatable possibly) and use it as the source for the
datagrid AND then the report."

I went into my report to use the CR DatabaseExpert and stumbled when
trying to decide what to put in for my datasource. My datasource for
the datagrid itself gets populated with this code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'lblWelcome.Tex t = "Hello " & Global.UserSecu rity.Fname.Trim &
" " & Global.UserSecu rity.Lname
Dim act As Action
Dim pos As Position
Dim empname As String
Dim lvi As ListItem
Dim Employee As Employee
Dim empcount As Integer
act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
m_department = pos.Department. Name
Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
Dim dt As New DataTable
Dim count As Integer = 0
For Each emp As Employee In emps
SetListViewItem (emp, dt, count)
count = count + 1
Next
dgEmployees.Dat aSource = dt
dgEmployees.Dat aBind()
End Sub
Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add( "Emp #")
dt.Columns.Add( "Last Name")
dt.Columns.Add( "First Name")
dt.Columns.Add( "Title")
End If
Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
Dim employee As DataRow = dt.NewRow
employee("Emp #") = dr.Key
employee("Last Name") = dr.LastName

employee("First Name") = dr.FirstName
employee("Title ") = EmpPos.WorkAgai nstInfo.Title
dt.Rows.Add(emp loyee)
End Sub 'SetListViewIte m

The immediate challenge is that the datasource I was given by the
powers that be was a precompiled DLL with stored procedures and
database connections made to an Oracle database. So I didn't know the
foggiest idea of how the above code could be adapted/used to provide
CR with its data needs. I thought it might be in this specific case
more manageable for this newbie to find a way of using the datagrid as
the CR source (not that I know how to approach that either). But I can
see the challenges with caching and viewstate in a more complex page
than what I'm doing.

So any clues would be great... thanks! Brockus

On Jul 21, 12:54 pm, "sloan" <sl...@ipass.ne twrote:
I already responded to this post last week.
..
Did you attempt my advice?
"Brock" <wade.br...@yah oo.comwrote in message
news:61******** *************** ***********@r66 g2000hsg.google groups.com...
>I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.
I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?
How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how in CR
do I tell it that this resultingDataSe t is what it needs for the
report?
I found a snippet of code that may work as PART of the solution, but I
need a little direction.
Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
End Sub- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Jul 21 '08 #6
Hi Sloan... another poster on 'microsoft.publ ic.dotnet.langu ages.vb'
suggested using something like:

MyCrystalReport .SetDataSource( MyDataGrid.Data Source)

- to set the CR datasource... I'm guessing placing that in my code-
behind .aspx.vb (?) - maybe in the event handler for a button that
displays the reportViewer?
If that's the case would I go into the CR Datasource wizard and spell-
out something to let CR know this is where to look? My CR I'm writing
resides as an object in the actual project, but I don't know how much
CR recognizes datasources and how explicit the location needs to
read... thanks! Brockus
On Jul 21, 4:43*pm, "sloan" <sl...@ipass.ne twrote:
Session:http://www.aspfree.com/c/a/ASP.NET/A...ion-Objects-in...

Session belongs to Asp.Net, not CR.

..........

This is where you can store an object for later retrieval ( after a page
displays ).

"Brock" <wade.br...@yah oo.comwrote in message

news:fb******** *************** ***********@c58 g2000hsc.google groups.com...
My apologies, but I'm a real newbie on several key issues. One is how
to access the "Session" and again how to specify in CR itself what its
datasource is.

On Jul 21, 3:11 pm, "sloan" <sl...@ipass.ne twrote:
Ok, since you're in a web world...you gotta keep some stuff straight.
Your attempt to "re-get" the DataSource ~from~ the DataGrid after the page
is rendered is not a good strategy.
You also need to remember that once a page displays, alot of things you
had
in the code behind are not there anymore, unless you specifically save
them
somewhere.
(Like the Session as the usual suspect).
So I will outline something that I think is the correct approach.
On the page_load...... ..
Populate your source data (dataset) however you normally do this. I
will call this the model from now on.
Put the model in the Session object using a unique keyname.
Bind the model to the DataGrid you have on the page already.
You now have two things:
1. The original data inside the Session object.
2. A ~display~ of the original data on the user's browser.
The user makes changes.
Now you need to COLLECT the information the user changed by iterating
over all the rows in the datagrid, and pulling out the values.
Tip: Use a hidden object for those pieces of information you don't
want to display, but want to keep around.
Put this data into a new dataset (a new "model").
You can throw this into the Session object as well (if you want to) with
a DIFFERENT key name.
Optional:
Use the model(1) and the model(2) and create a massaged version of
the data.
Take the new model , and use the PUSH method to populate the Crystal
Report.
PS
You should be able to bind the datagrid aganst this object
Dim emps As Employees
without artificially converting it to a dataset/datatable. Have you tried
this yet?
"Brock" <wade.br...@yah oo.comwrote in message
news:84******** *************** ***********@m73 g2000hsh.google groups.com....
I tried to adapt your method, well I should say I got totally lost in
the process. Back to your reply, ad I do appreciate the help:
"I would go with the PUSH method of CR (crystal report) development.
And instead of worrying about the datagrid as the SOURCE, cache
(session?)
the dataset (or datatable possibly) and use it as the source for the
datagrid AND then the report."
I went into my report to use the CR DatabaseExpert and stumbled when
trying to decide what to put in for my datasource. My datasource for
the datagrid itself gets populated with this code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'lblWelcome.Tex t = "Hello " & Global.UserSecu rity.Fname.Trim &
" " & Global.UserSecu rity.Lname
Dim act As Action
Dim pos As Position
Dim empname As String
Dim lvi As ListItem
Dim Employee As Employee
Dim empcount As Integer
act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
m_department = pos.Department. Name
Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
Dim dt As New DataTable
Dim count As Integer = 0
For Each emp As Employee In emps
SetListViewItem (emp, dt, count)
count = count + 1
Next
dgEmployees.Dat aSource = dt
dgEmployees.Dat aBind()
End Sub
Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add( "Emp #")
dt.Columns.Add( "Last Name")
dt.Columns.Add( "First Name")
dt.Columns.Add( "Title")
End If
Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
Dim employee As DataRow = dt.NewRow
employee("Emp #") = dr.Key
employee("Last Name") = dr.LastName
employee("First Name") = dr.FirstName
employee("Title ") = EmpPos.WorkAgai nstInfo.Title
dt.Rows.Add(emp loyee)
End Sub 'SetListViewIte m
The immediate challenge is that the datasource I was given by the
powers that be was a precompiled DLL with stored procedures and
database connections made to an Oracle database. So I didn't know the
foggiest idea of how the above code could be adapted/used to provide
CR with its data needs. I thought it might be in this specific case
more manageable for this newbie to find a way of using the datagrid as
the CR source (not that I know how to approach that either). But I can
see the challenges with caching and viewstate in a more complex page
than what I'm doing.
So any clues would be great... thanks! Brockus
On Jul 21, 12:54 pm, "sloan" <sl...@ipass.ne twrote:
I already responded to this post last week.
..
Did you attempt my advice?
"Brock" <wade.br...@yah oo.comwrote in message
>news:61******* *************** ************@r6 6g2000hsg.googl egroups.com....
I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.
I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?
How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how inCR
do I tell it that this resultingDataSe t is what it needs for the
report?
I found a snippet of code that may work as PART of the solution, but I
need a little direction.
Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
End Sub- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
Jul 22 '08 #7

I know he drilled you about it already....but I'll throw another reminder

"another poster on 'microsoft.publ ic.dotnet.langu ages.vb'
suggested using something like:"

That's why multi posting stinks, because you get disjoint conversations
going.
So we'll let this ~one~ slide.

...

You'll have to experiment with the syntax he gave you.

...

However. You need to list out what is happening as regards to
page-life-time.

Are you trying to populate the datagrid and the CR on the same page request?

Or are you trying to populate the datagrid on one page request....and the CR
on another (second) page request.

If the latter, then I'm still in favor of what I told you before...about
putting the (populated) dataset into Session memory.

...

I know you're a newbie, at the same time, the most basic concepts you need
to get straight are:

1. Lifetime/cycle of a single page request.
2. How to put objects (like your populated dataset object) into the Session
object.

...
"Brock" <wa********@yah oo.comwrote in message
news:6e******** *************** ***********@m3g 2000hsc.googleg roups.com...
Hi Sloan... another poster on 'microsoft.publ ic.dotnet.langu ages.vb'
suggested using something like:

MyCrystalReport .SetDataSource( MyDataGrid.Data Source)

- to set the CR datasource... I'm guessing placing that in my code-
behind .aspx.vb (?) - maybe in the event handler for a button that
displays the reportViewer?
If that's the case would I go into the CR Datasource wizard and spell-
out something to let CR know this is where to look? My CR I'm writing
resides as an object in the actual project, but I don't know how much
CR recognizes datasources and how explicit the location needs to
read... thanks! Brockus
On Jul 21, 4:43 pm, "sloan" <sl...@ipass.ne twrote:
Session:http://www.aspfree.com/c/a/ASP.NET/A...ion-Objects-in...

Session belongs to Asp.Net, not CR.

..........

This is where you can store an object for later retrieval ( after a page
displays ).

"Brock" <wade.br...@yah oo.comwrote in message

news:fb******** *************** ***********@c58 g2000hsc.google groups.com...
My apologies, but I'm a real newbie on several key issues. One is how
to access the "Session" and again how to specify in CR itself what its
datasource is.

On Jul 21, 3:11 pm, "sloan" <sl...@ipass.ne twrote:
Ok, since you're in a web world...you gotta keep some stuff straight.
Your attempt to "re-get" the DataSource ~from~ the DataGrid after the
page
is rendered is not a good strategy.
You also need to remember that once a page displays, alot of things you
had
in the code behind are not there anymore, unless you specifically save
them
somewhere.
(Like the Session as the usual suspect).
So I will outline something that I think is the correct approach.
On the page_load...... ..
Populate your source data (dataset) however you normally do this. I
will call this the model from now on.
Put the model in the Session object using a unique keyname.
Bind the model to the DataGrid you have on the page already.
You now have two things:
1. The original data inside the Session object.
2. A ~display~ of the original data on the user's browser.
The user makes changes.
Now you need to COLLECT the information the user changed by iterating
over all the rows in the datagrid, and pulling out the values.
Tip: Use a hidden object for those pieces of information you don't
want to display, but want to keep around.
Put this data into a new dataset (a new "model").
You can throw this into the Session object as well (if you want to) with
a DIFFERENT key name.
Optional:
Use the model(1) and the model(2) and create a massaged version of
the data.
Take the new model , and use the PUSH method to populate the Crystal
Report.
PS
You should be able to bind the datagrid aganst this object
Dim emps As Employees
without artificially converting it to a dataset/datatable. Have you
tried
this yet?
"Brock" <wade.br...@yah oo.comwrote in message
news:84******** *************** ***********@m73 g2000hsh.google groups.com...
I tried to adapt your method, well I should say I got totally lost in
the process. Back to your reply, ad I do appreciate the help:
"I would go with the PUSH method of CR (crystal report) development.
And instead of worrying about the datagrid as the SOURCE, cache
(session?)
the dataset (or datatable possibly) and use it as the source for the
datagrid AND then the report."
I went into my report to use the CR DatabaseExpert and stumbled when
trying to decide what to put in for my datasource. My datasource for
the datagrid itself gets populated with this code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'lblWelcome.Tex t = "Hello " & Global.UserSecu rity.Fname.Trim &
" " & Global.UserSecu rity.Lname
Dim act As Action
Dim pos As Position
Dim empname As String
Dim lvi As ListItem
Dim Employee As Employee
Dim empcount As Integer
act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
m_department = pos.Department. Name
Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
Dim dt As New DataTable
Dim count As Integer = 0
For Each emp As Employee In emps
SetListViewItem (emp, dt, count)
count = count + 1
Next
dgEmployees.Dat aSource = dt
dgEmployees.Dat aBind()
End Sub
Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add( "Emp #")
dt.Columns.Add( "Last Name")
dt.Columns.Add( "First Name")
dt.Columns.Add( "Title")
End If
Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
Dim employee As DataRow = dt.NewRow
employee("Emp #") = dr.Key
employee("Last Name") = dr.LastName
employee("First Name") = dr.FirstName
employee("Title ") = EmpPos.WorkAgai nstInfo.Title
dt.Rows.Add(emp loyee)
End Sub 'SetListViewIte m
The immediate challenge is that the datasource I was given by the
powers that be was a precompiled DLL with stored procedures and
database connections made to an Oracle database. So I didn't know the
foggiest idea of how the above code could be adapted/used to provide
CR with its data needs. I thought it might be in this specific case
more manageable for this newbie to find a way of using the datagrid as
the CR source (not that I know how to approach that either). But I can
see the challenges with caching and viewstate in a more complex page
than what I'm doing.
So any clues would be great... thanks! Brockus
On Jul 21, 12:54 pm, "sloan" <sl...@ipass.ne twrote:
I already responded to this post last week.
..
Did you attempt my advice?
"Brock" <wade.br...@yah oo.comwrote in message
>news:61******* *************** ************@r6 6g2000hsg.googl egroups.com...
I am trying to populate a Crystal Report from data in my DataGrid.
The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report reflect
the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset in memory that could be had directly
from the datagrid.
I'm guessing I need to Dim a new DataSet, populate it from the
datagrid, and set the new dataset as the datasource for CR. But how?
How can I specify that the Datagrid's DataSource property can be
explicitly cast as a DataSet object that CR can pick up. And how in
CR
do I tell it that this resultingDataSe t is what it needs for the
report?
I found a snippet of code that may work as PART of the solution, but
I
need a little direction.
Private Sub FillDataSet(ByV al DataFromGrid As DataSet)
DataFromGrid = CType(dgEmploye es.DataSource, DataSet)
End Sub- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Jul 22 '08 #8
"sloan" <sl***@ipass.ne twrote in message
news:Op******** ******@TK2MSFTN GP05.phx.gbl...
That's why multi posting stinks
Not as much as top-posting, though...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 22 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6914
by: Gheaci Maschl | last post by:
Hi all! I would like to have your opinion about my problem and my proposal how to solve it: Ingredients: - BTriev database - Crystal Reports - maybe MS Access - Liinos6 (small ERP software)
0
2500
by: Marco Martin | last post by:
Hi all, I need to figure the best solution to my problem. <Background> A Bill of materials application that has a treeview as the master and a datagrid as the details. The treeview holds both master and detail information but only displays a brief description. When a node is clicked, if the node has children, it displays all Child information in detail form in a datagrid. If it has no children, it simply displays itself as a row in
1
333
by: Islam Elkhayat | last post by:
I need to bind my query from the dataGrid to crystal Report... so the report displayed data depand on the datagrid.... I also hv alot of problem in the crystal report.. may i know a good online source to read about crystal report??
7
5011
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying. I created the websetup and built the MSI, have the bundled version. Copied to webserver and ran Websetup.msi. Said I had to remove old version, which I did, then reran WebSetup.msi and keeps giving me this error. "The installer was interrupted...
1
1339
by: KK | last post by:
Hi I run different kinds of queries and display the resulting data on a ASP.NET datagrid. I want to give a facility to let the user graph selected fields (if logicaly possible) using crystal reports. For example, if the query is;
3
1921
by: AAJ | last post by:
Hi all I use a 3 tier approach for my project, and all comms to the database is via a BLL layer. This works fine. I have been lazy in the past, and when reporting via crystal I have created a connection directly to the database view and recreated the parameters used on the web pages to display identical information, but in crystal. This has left me with two problems
1
2188
by: mike11d11 | last post by:
For some reason I'm getting no data populating in my crystal report. I built my crystal report off my dataset in my project, and I fill the dataset when opening the main form, and count the records just to make sure there is data in the dataset, and then open the form containing my reportviewer control with the crystal report added to it and it still shows no data when it opens. I built my crystal report off the wizard when right...
1
1949
by: Brock | last post by:
Thanks for any help. I'm not new to Crystal Reports and use them routinely in vb.net for desktop applications, but I don't know where to start for using them in my asp.net apps. I currently have an .aspx page with a datagrid populated by two compliled DLL's which make the fields available to the datagrid with this code below. Should I have a popup screen that contains the ReportViewer from the toolbox? How can I in my crystal report set...
3
2554
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly on my DataGrid but I'm not sure how to get Crystal Reports 10 to use as its datasource the dataset...
0
8555
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9112
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8824
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8817
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7651
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5831
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4336
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
1970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.