binding a repeater

F

francois

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
 
D

Dilip Krishnan

francois said:
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
 
G

Guest

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
 
F

francois

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top