binding a repeater

Discussion in 'ASP .Net' started by francois, Feb 10, 2004.

  1. francois

    francois Guest

    Hi,

    I have a little problem

    I am using a stored procedure to retrieve my date.
    What I want to achieve is to be able to "skip" some row from the resultset i
    retrieve back from the stored procedure. To be clear, when I Bind my
    repeater I want to be able to skip some records in my repeater and not
    display anything at all for that record. I do some calculation on the data i
    retrieve to decide if i will bind that row or not.

    In my code, in the itemDataBound even handler, I do not execute anything in
    the case My calculation decide that that specific record should not be
    binded. But my problem is that the row of the repeater is still displayed
    eventho there is no data inside (as for that row, i do not assign any value
    to the controls of that row)

    I hope I am clear...

    the code look like

    in the page_load

    reader = cmd.ExecuteReader();
    RepeaterPriceChange.DataSource = reader;
    RepeaterPriceChange.DataBind();
    reader.Close();

    in the ItemDataBound event handler of the Repeater

    if (condition == true)
    {
    // get values for this record and assign them to the controld in the
    columns of the current row of the repeater
    }
    else
    {
    // skip this record (does not work property, the repeater still display
    a row with empty values in the controls of that row
    }


    Then is it possible to skip and all row of repeater? If yes how to do?

    Best regards,

    francois
    francois, Feb 10, 2004
    #1
    1. Advertising

  2. francois wrote:

    > Hi,
    >
    > I have a little problem
    >
    > I am using a stored procedure to retrieve my date.
    > What I want to achieve is to be able to "skip" some row from the resultset i
    > retrieve back from the stored procedure. To be clear, when I Bind my
    > repeater I want to be able to skip some records in my repeater and not
    > display anything at all for that record. I do some calculation on the data i
    > retrieve to decide if i will bind that row or not.
    >
    > In my code, in the itemDataBound even handler, I do not execute anything in
    > the case My calculation decide that that specific record should not be
    > binded. But my problem is that the row of the repeater is still displayed
    > eventho there is no data inside (as for that row, i do not assign any value
    > to the controls of that row)
    >
    > I hope I am clear...
    >
    > the code look like
    >
    > in the page_load
    >
    > reader = cmd.ExecuteReader();
    > RepeaterPriceChange.DataSource = reader;
    > RepeaterPriceChange.DataBind();
    > reader.Close();
    >
    > in the ItemDataBound event handler of the Repeater
    >
    > if (condition == true)
    > {
    > // get values for this record and assign them to the controld in the
    > columns of the current row of the repeater
    > }
    > else
    > {
    > // skip this record (does not work property, the repeater still display
    > a row with empty values in the controls of that row
    > }
    >
    >
    > Then is it possible to skip and all row of repeater? If yes how to do?
    >
    > Best regards,
    >
    > francois
    >
    >

    Francois,
    Try using a templated control for this purpose. Its probably much
    easier. Alternatively use the stored proc to only retreive the rows you
    want to display
    Hope that helps

    --
    Regards,
    Dilip Krishnan
    dilip removethis @ msn.com
    Dilip Krishnan, Feb 10, 2004
    #2
    1. Advertising

  3. Why don't take care of this inside the store procedure, should even improve its performance? Doesn't look like to me that needs to be dynamic or correct me if I am wrong

    Rez


    ----- francois wrote: ----

    Hi

    I have a little proble

    I am using a stored procedure to retrieve my date
    What I want to achieve is to be able to "skip" some row from the resultset
    retrieve back from the stored procedure. To be clear, when I Bind m
    repeater I want to be able to skip some records in my repeater and no
    display anything at all for that record. I do some calculation on the data
    retrieve to decide if i will bind that row or not

    In my code, in the itemDataBound even handler, I do not execute anything i
    the case My calculation decide that that specific record should not b
    binded. But my problem is that the row of the repeater is still displaye
    eventho there is no data inside (as for that row, i do not assign any valu
    to the controls of that row

    I hope I am clear..

    the code look lik

    in the page_loa

    reader = cmd.ExecuteReader()
    RepeaterPriceChange.DataSource = reader
    RepeaterPriceChange.DataBind()
    reader.Close()

    in the ItemDataBound event handler of the Repeate

    if (condition == true

    // get values for this record and assign them to the controld in th
    columns of the current row of the repeate

    els

    // skip this record (does not work property, the repeater still displa
    a row with empty values in the controls of that ro



    Then is it possible to skip and all row of repeater? If yes how to do

    Best regards

    francoi
    =?Utf-8?B?cmV6YXM=?=, Feb 10, 2004
    #3
  4. francois

    francois Guest

    Actually the conditions are too complex to put in a stored procedure, then I
    was wondering if it is not possible to just skip a rows in the repeater. Or
    maybe I am not good enough at stored procedure :p

    Anyway I will continue to look on the stored procedure side but It would be
    neat to be able to have some way to "filter" out some records while you do
    databinding. Maybe then I should use a DataSet instead of a reader, do some
    logic on it and remove the rows 'manually' ... ugly and my point is to know
    if it is possible to skip a row in the repeater but it seems like it is not.


    Also I am quite new in asp.net, then what is a templated control? Excuse my
    ignorance

    Best regards and thank you for your answer :) It conforts me to go for the
    sp for now

    Francois


    "Dilip Krishnan" <> wrote in message
    news:uceZDM$...
    > francois wrote:
    >
    > > Hi,
    > >
    > > I have a little problem
    > >
    > > I am using a stored procedure to retrieve my date.
    > > What I want to achieve is to be able to "skip" some row from the

    resultset i
    > > retrieve back from the stored procedure. To be clear, when I Bind my
    > > repeater I want to be able to skip some records in my repeater and not
    > > display anything at all for that record. I do some calculation on the

    data i
    > > retrieve to decide if i will bind that row or not.
    > >
    > > In my code, in the itemDataBound even handler, I do not execute anything

    in
    > > the case My calculation decide that that specific record should not be
    > > binded. But my problem is that the row of the repeater is still

    displayed
    > > eventho there is no data inside (as for that row, i do not assign any

    value
    > > to the controls of that row)
    > >
    > > I hope I am clear...
    > >
    > > the code look like
    > >
    > > in the page_load
    > >
    > > reader = cmd.ExecuteReader();
    > > RepeaterPriceChange.DataSource = reader;
    > > RepeaterPriceChange.DataBind();
    > > reader.Close();
    > >
    > > in the ItemDataBound event handler of the Repeater
    > >
    > > if (condition == true)
    > > {
    > > // get values for this record and assign them to the controld in the
    > > columns of the current row of the repeater
    > > }
    > > else
    > > {
    > > // skip this record (does not work property, the repeater still

    display
    > > a row with empty values in the controls of that row
    > > }
    > >
    > >
    > > Then is it possible to skip and all row of repeater? If yes how to do?
    > >
    > > Best regards,
    > >
    > > francois
    > >
    > >

    > Francois,
    > Try using a templated control for this purpose. Its probably much
    > easier. Alternatively use the stored proc to only retreive the rows you
    > want to display
    > Hope that helps
    >
    > --
    > Regards,
    > Dilip Krishnan
    > dilip removethis @ msn.com
    francois, Feb 10, 2004
    #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. Jordan
    Replies:
    2
    Views:
    2,528
    Jordan
    Feb 10, 2004
  2. Amit
    Replies:
    6
    Views:
    13,782
    Assimalyst
    Oct 24, 2006
  3. Replies:
    2
    Views:
    853
    Kevin Grover
    Oct 20, 2006
  4. JcFx
    Replies:
    0
    Views:
    274
  5. Vivek Nallur

    value binding and function binding

    Vivek Nallur, Sep 25, 2003, in forum: Ruby
    Replies:
    0
    Views:
    135
    Vivek Nallur
    Sep 25, 2003
Loading...

Share This Page