Activereports work summary 2 -- Data Source binding

Source: Internet
Author: User

Khan: I haven't updated my blog for a long time. My baby was just born, busy with bringing children, and busy with work. I really don't have the energy to update my blog ·@_@

The last simple example shows a simple ar template. However, in reality, we generally require ar to display a specific set of data, which may be a data table, it may also be an array.

At this time, we need to bind the data to our ar template. Ar2.0 supports the following data sources:
Dataset
Datatable
Dataview
Ilistsource

Bind the data sourceCodeAs follows:

' Example
Dim RPT As   New Arsimpleexample

'Specify the data source as mytable
Rpt. datasource=Mytable
Rpt. datamember
=Mytable. tablename

'Show Ar Template
Me. Viewer1.document=Rpt. Document
Rpt. Run ()

For example, if I have a studeng table, the structure is as follows:
No name
1 Tom
2 John
3 Mary


I want to display them to the AR template. We have the following work to do:
1. In our form frmshowar_load event, bind the data source (BIND mytable to the AR template). The Code is as follows:

' ''-----------------------------------------------------------------------------
' ''<Summary>
' ''Form load event
' ''</Summary>
' ''<Param name =" sender "> </param>
' ''<Param name =" E "> </param>
' ''<Remarks>
' ''Form load: Upload the AR template to the viewer container.
' ''</Remarks>
' ''<History>
' ''[Tonygong] 6/5/2006 created
' ''</History>
' ''-----------------------------------------------------------------------------
Private   Sub frmshowar_load () Sub Frmshowar_load ( Byval Sender As System. object, Byval E As System. eventargs) Handles   Mybase . Load
Try
' Create a talbe in the following format:
' No name
' 1 Tom
' 2 John
' 3 Mary
Dim Mytable As   New Datatable
Mytable. Columns. Add (
" No " )
Mytable. Columns. Add (
" Name " )

Dim Myrow As Datarow
Myrow
= Mytable. newrow ()
Myrow (
" No " ) =   " 1 "
Myrow (
" Name " ) =   " Tom "
Mytable. Rows. Add (myrow)

Myrow
= Mytable. newrow ()
Myrow (
" No " ) =   " 2 "
Myrow (
" Name " ) =   " John "
Mytable. Rows. Add (myrow)

Myrow
= Mytable. newrow ()
Myrow (
" No " ) =   " 3 "
Myrow (
" Name " ) =   " Mary "
Mytable. Rows. Add (myrow)



' Example
Dim RPT As   New Arsimpleexample

' Specify the data source as mytable
Rpt. datasource = Mytable
Rpt. datamember
= Mytable. tablename


' Show Ar Template
Me . Viewer1.document = Rpt. Document
Rpt. Run ()

Catch Ex As Exception
MessageBox. Show (ex. tostring)
End   Try

2. After the data source is bound, the AR template obtains all values of mytable and then displays these values.
Add several controls to the AR template to display data,

Open our template and add two lable controls in pageheader to display the title. Change the text attributes to "" and "name" respectively"

Then, add two textbox controls in detail to display the NO and name of the student.
The key attribute is datafield. Enter the columns to be bound to the textbox,

3. OK. It's very easy. After setting the above two steps, it will be displayed normally. Press F5 and the effect is as follows:

The result is displayed, but it is a little ugly. Change the layout (change the height of pageheader and detail to the height of the control) and add a border to each control (right-click the control, select format border) and change it to the following:

Run it again. It looks much better.

Download this section of code: http://files.cnblogs.com/batoosai/SimpleExample2.rar

The next section describes the data breakdown and form feed (for example, if there are two class students, each page shows one class student)

Environment: vb2003 + ar2.0

C # data binding, cure wrote an article,
Http://www.cnblogs.com/dahuzizyd/archive/2006/07/18/453690.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.