单击gridview链接按钮时,可在Crystal Report中查看记录 [英] view the record in Crystal Report when click on gridview Linkbutton

查看:81
本文介绍了单击gridview链接按钮时,可在Crystal Report中查看记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
你们中的任何一个都会帮助我解决这个问题..
我在gridview中有一列,单击该列时也将具有链接按钮"select",该链接按钮将转到Crystal Report页面,并在Crystal Report页面中显示此行记录.
我正在使用Crystal Report查看器.
请对此进行指导.
rgds,
Aleesya

Hi everyone,
any one of you will help me to solve this problem..
I have a column in a gridview which will be also have Link Button Called "select" when it is clicked it will go to the crystal report page and show this row record in crystal report page.
I am using Crystal Report viewer.
Please guide me on this.
rgds,
Aleesya

推荐答案

您需要做的只是在选择"单击时调用水晶报表页面.将记录的唯一ID传递到该页面,以便您可以查询数据库以获取与报表相关的数据.

看看这些文章,以获取所需的知识:
动态Crystal报表查看 [具有C#的动态Crystal报表 [ .NET中的Crystal Reports简介 [使用其功能组,图形,交叉表和子报表逐步创建Crystal报表 [ ^ ]
ASP.NET中的晶体报告 [
All you need is to call the crystal report page on ''select'' click. Pass on the unique ID of that record to that page such that you can query the DB for the data related to it to be shown in report.

Have a look at these articles to get equipped with knowledge needed for it:
Dynamic Crystal Reports Viewing[^]
Dynamic Crystal Report with C#[^]

Few features step-by-step:
Introductions to Crystal Reports in .NET[^]
Step by Step Creation of Crystal Report using its Features Group, Graph, Cross-Tab and Sub Report[^]
Crystal Reports in ASP.NET[^]

Read and try!


希望这可以解决您的问题.
根据我所做的
我有两种形式Form1和Form2
在Form2中,Form1获得了CR查看器,而Form2获得了带有Select按钮的gridview. 我写了一个函数来显示Db中的数据,并在GridView中显示它,如:
May this will Solve Your problem.
As Per What I did
I have two forms Form1 and Form2
Form1 has Got the CR viewer and Form2 A gridview With Select button .I will also State that how I have Added The gridview button and Coulumns here .In Form2
I wrote a function to Display the Data from Db and to show it in the GridView Like :
Public Sub dataDisp()
        Dim sd As New SqlDataAdapter("Select * from Product", Mycon.con())
        Dim dt As New DataTable
        sd.Fill(dt)
        If dt.Rows.Count > 0 Then
            dGview.DataSource = dt

            Dim dgButtonColumn As New DataGridViewButtonColumn
            dgButtonColumn.HeaderText = ""
            dgButtonColumn.UseColumnTextForButtonValue = True
            dgButtonColumn.Text = "Select"
            dgButtonColumn.Name = "Select"
            dgButtonColumn.ToolTipText = "Select"
            dgButtonColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader
            dgButtonColumn.FlatStyle = FlatStyle.System
            dgButtonColumn.DefaultCellStyle.BackColor = Color.Gray
            dgButtonColumn.DefaultCellStyle.ForeColor = Color.White
            dGview.Columns(0).Visible = False
            dGview.Columns.Add(dgButtonColumn)
        End If
    End Sub



之后,我在FormLoad事件上调用此函数,也可以单击按钮以调用此函数以将数据加载到GridView中.
在这里,我使用了一个名为产品"的数据库表
然后在dGview_CellContentClick事件下检查是否按下了Select按钮,如:



After That i call This Function On the FormLoad Event or you Can take A button to Call This Function to Load the Data in the GridView.
Here I have Used A database table named "Product"
And then under dGview_CellContentClick Event checked that if Select button is Pressed Like :

Private Sub dGview_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dGview.CellContentClick
       If sender.Columns(e.ColumnIndex).Name = "Select" Then
           Form1.Show()
       End If
   End Sub



如果按下了选择"按钮,则调用Form1或说包含CR查看器的表单

现在如何加载报告因此,在这里我还使用了一个函数来提取数据表单Db并将其加载到Report中,如下所示:



And if the Select Button is Pressed Call the Form1 or Say the Form Containing the CR viewer

And Now how to Load the report So, here Also I used a Function To Extract the Data form Db and to load it in the Report Like:

Private Sub MyReportCRYSTAL()

        Dim sd As New SqlDataAdapter("Select * from Product where Product_id=''" & Form2.dGview.SelectedCells.Item(0).Value & "''", Mycon.con())
        Dim dt As New DataTable
        sd.Fill(dt)
        If dt.Rows.Count > 0 Then
            Dim pr As New ProductReport()
            pr.SetDataSource(dt)
            CrystalReportViewer1.ReportSource = pr
            CrystalReportViewer1.RefreshReport()
        End If
    End Sub


这里的ProductReport是我根据表格产品中的字段设计的CrystalReport
在表单加载事件上调用此函数.因此,每当您单击选择"按钮时,都会打开该表单,并且必填报表也会加载到表单上.
我还假设您在gridview中具有Id字段,我正在将Select查询的where子句作为"Form2.DataGridViewName.SelectedCells.Item(0).Value"传递给
myCon是连接类.
仅此而已.尝试一下可以正常使用


Here ProductReport is the CrystalReport what i ihave Designed taking the Fields from the Table Product
Call This Function On the Form Load Event.So that whenever You click the Select Button this Form opens and the Required Report also get loaded on the form load
Also I assume that You have the Id Field in the gridview which I am passing in the where Clause of the Select Query as "Form2.DataGridViewName.SelectedCells.Item(0).Value"
myCon is the Connection Class.
That''s All.Try This Will Work Fine


这篇关于单击gridview链接按钮时,可在Crystal Report中查看记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆