Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Report and asp.net web form 1

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
Hi all,
I have created sucessfully a crystal report and also I have a webform that I set up to pass a value to crystal report. My question is the following:

What class do I need to import to work with the crystal reprot? We have a server set up for the crystal reprot?

any good tutorial for this please help. thank you

 
Hi,
It depends...There are several depending on what you need the report to do..In addition, you do not need ANY if you build a URL with the values needed and redirect to that URL.

Take a look here for ideas from both the Crystal Reports SDK info and the Business Objects SDKs..

Be sure the server has the .NET assemblies installed.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
thank you Turkbear for the response. Here is my situation I have my aspx page that returns value in a gridview and the user ask me if there is a way to have a check box within a gridview and select the project in order for them so see the detail of the project. I talk with the Crystal Server team and they say there is a server dedicated for that. I try to google to see if there is any tutorial or example that fit my need and I could not find any. I really appreciate how I can pass the value from the selected checkboxes from the gridview pass that to the report I have in Crystal server and generate a pdf file.

My first questin is how do make the crystal server talk to asp.net form
 
thank you Jason for the above example. I did something similar to this one. and my question is how can I pass the values from this to the crystal report. It is easy if it was like dropdown or listbox but I have never done passing values from checkbox embeded in a gridview control. your help is appreciated.

Protected Sub btnJobs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnJobs.Click

Dim names As ArrayList = New ArrayList()

For Each gvRows As GridViewRow In gvItemDetail.Rows
Dim chkSelect As CheckBox = CType(gvRows.FindControl("chkSelect"), CheckBox)
If chkSelect.Checked Then
Dim ContractID As String = (gvItemDetail.DataKeys(gvRows.RowIndex)("contid"))
names.Add(ContractID)
End If
Next

End Sub




If CType(Formctl, Panel).Visible = True Then
For Each Panelclt In CType(Formctl, Panel).Controls

If Panelclt.GetType() Is GetType(ListBox) Then

NamStr = NamStr & CType(Panelclt, ListBox).ID & ","
For ix = 0 To CType(Panelclt, ListBox).Items.Count - 1

If CType(Panelclt, ListBox).Items(ix).Selected Then
ValStr = ValStr & CType(Panelclt, ListBox).Items(ix).Value & ","
End If

Next ' ix

ValStr = Left(ValStr, Len(ValStr) - 1) & ";"

end if
 
here is my gridview just in case
{code}
<asp:GridView ID="gvItemDetail" runat="server" CellPadding="4" BackColor="PapayaWhip" ForeColor="#333333"
Width="100%" AutoGenerateColumns="False" DataKeyNames="contid"
EnableViewState="False"
Font-Bold="False">
<PagerSettings Position="Top" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="False" ForeColor="White" />

<Columns>


<asp:TemplateField>
<ItemStyle Width="40px" HorizontalAlign="Center" />
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>


<asp:BoundField DataField="pubDate" HeaderText="Advertisement Published Date">
<ItemStyle Font-Size="Smaller" Font-Italic="True" Wrap="False" Font-Bold="True" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="Sp" HeaderText="S.P. Number">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="Route Number" HeaderText="Route Number">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="DistrictId" HeaderText="District Name">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="LetDate" HeaderText="Letting Date">
<ItemStyle Font-Size="Smaller" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>


<asp:BoundField DataField="contid" HeaderText="Contract Id">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="FULLDESC" HeaderText="Other S.P(s),Route Number, Project Location, Work Type...">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" Font-Bold="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>


</Columns>



</asp:GridView>
{code}
 
this makes sense
Code:
Protected Sub btnJobs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnJobs.Click

        Dim names As ArrayList = New ArrayList()

        For Each gvRows As GridViewRow In gvItemDetail.Rows
            Dim chkSelect As CheckBox = CType(gvRows.FindControl("chkSelect"), CheckBox)
            If chkSelect.Checked Then
                Dim ContractID As String = (gvItemDetail.DataKeys(gvRows.RowIndex)("contid"))
                names.Add(ContractID)
            End If
        Next

    End Sub
you now have a list of names you can do something with

however, this does't make any sense
Code:
  If CType(Formctl, Panel).Visible = True Then
                    For Each Panelclt In CType(Formctl, Panel).Controls
                        If Panelclt.GetType() Is GetType(ListBox) Then
                            NamStr = NamStr & CType(Panelclt, ListBox).ID & ","
                            For ix = 0 To CType(Panelclt, ListBox).Items.Count - 1
                                If CType(Panelclt, ListBox).Items(ix).Selected Then
                                    ValStr = ValStr & CType(Panelclt, ListBox).Items(ix).Value & ","
                                End If
                            Next  ' ix                
                            ValStr = Left(ValStr, Len(ValStr) - 1) & ";"
end if
reviewing the datagrid, each row looks to be a unique record, and each would link to it's own report. If this is true, then don't use a checkbox, use a hyperlink instead and link to the report. if you want the report to open in a new windows set the target to blank.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
thank you Jason again for your reply. The reason I use a checkbox is inorder for the user to select one or more projects to see the detail of the selected projects.If I use hyperlink I do not know how they can select more than one projects to see the details. How can I change the second code to work for checkbox not for listbox? thank you
 
How can I change the second code to work for checkbox not for listbox?
using the code in the btnJobs_Click handler you have a list of project detail ids. from there you can do whatever you want with them.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
sorry if I keep asking the same question. I still do not have a clue how I can pass multiple value into the crystal reprot when the user select a check box.I really appreciate your time and help and hopefully I will find a way to do this. thak you
 
how the user selects the data and how the report is requested are independent operations, assuming you access the report via a url.

say the url is

how you get parameters a and b do not matter. they could come from a cookie, session, database, user input.
forming the url is independent of where the data comes from.

now in your case you want to pass a collection/array of values. this is a little more tricky, but not impossible. depending on how the service behind the url consumes the parameters it may look like
[]=1&parameter[]=2
[0]=1&parameter[1]=2
or something completely different. you'll have to work this out with the developers creating the report services.

even if you are not using a url to access the reports. the concept separating the collection of parameters and requesting the report still apply.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I do not have a word to express my appreciation for your willingness to help out people like me with no depth knowledge of .net. thank you very much and I will look into your example and hopefully It will work for me.
 
your welcome. when you have some time check out the SOLID design principles. chad myers has a popular post on the subject. other bloggers has series on applying these concepts to legacy code.

it's worth the time to learn and will change your approach to how you write code.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Jason, as a quick fix I did it this way. I will explore more and find a better to do this.like get the reprot id from the server instead of hardcoding the report id...like i said it was kind of urgent and it does what the customer is looking for. thank you again for your tips and valuable link.

Dim NamStr As String = ""
Dim LocStr As String = ""
Dim ValStr As String = ""
Dim reportId As Integer = 5721347
NamStr = "Contractid"
Dim NumP As Integer = 1
For Each gvRows As GridViewRow In gvItemDetail.Rows
Dim chkSelect As CheckBox = CType(gvRows.FindControl("chkSelect"), CheckBox)
If chkSelect.Checked Then
ValStr = ValStr & (gvItemDetail.DataKeys(gvRows.RowIndex)("contid")).ToString.Trim & ","
End If
Next
ValStr = Left(ValStr, Len(ValStr) - 1) & ";"
Dim Urlval As New UrlType
LocStr = Urlval.GetUrl & reportId & "&Pnames=" & NamStr & "&Pvals=" & ValStr & "&NumParens=" & NumP
Response.Redirect(LocStr)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top