ReportView + SQLDataSource (dinamically defined)

Discussion in 'ASP .Net' started by slY, Jan 11, 2010.

  1. slY

    slY Guest

    hi all!

    I'm trying to link a SQLDataSource to a Reportview dinamically in this way:

    in Print.aspx I set

    <rsweb:ReportViewer ID="RptViewFoo" runat="server" Font-Names="Verdana"
    Font-Size="8pt"
    Height="400px" Width="966px">
    <LocalReport ReportPath="Print\Foo.rdlc">
    <DataSources>
    <rsweb:ReportDataSource DataSourceId="SQLDSFoo" Name="Report_Foo" />
    </DataSources>
    </LocalReport>
    </rsweb:ReportViewer>
    <asp:SqlDataSource ID="SQLDSFoo" runat="server" ConnectionString="<%$
    ConnectionStrings:_FOO_ConnectionString %>"
    ></asp:SqlDataSource>



    then, in the code behind I use code like

    ....
    ElseIf (stampType = "Foo") Then
    If Not (IDUser = "") Then
    Try
    SQLDSFoo.SelectParameters.Clear()
    SQLDSFoo.SelectParameters.Add("id_user",
    Type.GetTypeCode(Type.GetType("Integer")), IDUser) 'IDUser is loaded via
    Query-String
    SQLDSFoo.SelectCommand = "SELECT * FROM [PRINT_FOO] AS X WHERE
    X.id_user = @id_user"
    SQLDSFoo.Select(Nothing)
    RptViewFoo.DataBind()

    SQLDSFoo.UpdateParameters.Clear()
    SQLDSFoo.UpdateParameters.Add("id_user",
    Type.GetTypeCode(Type.GetType("Integer")), IDUser)
    SQLDSFoo.UpdateCommand = "dbo.procedure_UDPATE_FOO_PRINTED @id_user"
    ...

    Does it make sense?

    Sorry, but I cannot use debug mode with this project!
     
    slY, Jan 11, 2010
    #1
    1. Advertising

  2. slY <> wrote in
    news:eMq$:

    > hi all!
    >
    > I'm trying to link a SQLDataSource to a Reportview dinamically in this
    > way:
    >
    > in Print.aspx I set
    >
    > <SNIPPED CODE>
    >
    > Does it make sense?



    If you are going through the motions of customizing the data transport,
    why would you want to use a SqlDataSource control. The idea behind
    DataSource is you drag and drop, set and forget.

    This blog entry might better explain why I am asking why you are doing
    this:

    http://bit.ly/8MCMDK

    If you end up with a lot of customization, you might as well bite the
    bullet and create a data layer rather than attempt to customize an "all
    in one" control.

    > Sorry, but I cannot use debug mode with this project!


    Why?

    Peace and Grace,

    --
    Gregory A. Beamer (MVP)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Jan 11, 2010
    #2
    1. Advertising

  3. slY

    slY Guest

    Il 11/01/2010 16.03, Gregory A. Beamer ha scritto:
    > This blog entry might better explain why I am asking why you are doing
    > this:
    >
    > http://bit.ly/8MCMDK
    >

    Thank you, I'm reading your article very carefully.

    > If you end up with a lot of customization, you might as well bite the
    > bullet and create a data layer rather than attempt to customize an "all
    > in one" control.


    At the moment I know what you mean, but I'm pretty new to ASP.NET
    programming (and web programming in general), so please excuse the lack
    of orthodoxy in the approach to the subject.


    The fact is that the page return a PDF, so there is no interaction with
    the user, even when updating! (I use UpdateCommand to launch a store
    procedure that marks the involved records as printed...

    The "business" of the page is defined entirely by the query-string,
    covering four cases:

    - two kinds of stamp (by default, when there is no user ID in the
    query-string, all the users will be involved in the PDF report):

    Print.aspx?stampType=kind_a
    Print.aspx?stampType=kind_b


    - the two kindx of stamp for the single user (in this case only the
    single record related to the user will be printed):

    Print.aspx?stampType=kind_a&IDUser=1
    Print.aspx?stampType=kind_a&IDUser=2
    Print.aspx?stampType=kind_a&IDUser=3
    ....

    Print.aspx?stampType=kind_b&IDUser=1
    Print.aspx?stampType=kind_b&IDUser=2
    Print.aspx?stampType=kind_b&IDUser=3
    ....


    Any suggestions or help will be appreciated!
     
    slY, Jan 11, 2010
    #3
  4. slY

    slY Guest

    Il 11/01/2010 16.03, Gregory A. Beamer ha scritto:
    > If you end up with a lot of customization, you might as well bite the
    > bullet and create a data layer rather than attempt to customize an "all
    > in one" control.


    Any advise or article about how to face the design of a proper data layer?

    Thank you very much.
     
    slY, Jan 15, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JMMB

    Creating JavaScript Dinamically

    JMMB, Aug 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    423
    Kevin Spencer
    Aug 26, 2003
  2. Umut Tezduyar
    Replies:
    2
    Views:
    536
    Umut Tezduyar
    Nov 10, 2003
  3. Casper
    Replies:
    4
    Views:
    720
    Casper
    Feb 7, 2007
  4. Oodini
    Replies:
    1
    Views:
    1,779
    Keith Thompson
    Sep 27, 2005
  5. Casper
    Replies:
    4
    Views:
    795
    Casper
    Feb 7, 2007
Loading...

Share This Page