Don't do things in mid-stream. Use PreRender event when the datalist has
been already fully built. At this stage you can hide unwanted items with
setting their Visible property to false. It will have the same effect as
deleting them from the datalist since they won't be rendered to the
client.
thanks for the reply .. but that's the kind of hack I prefer to avoid if
possible
you've never terminated a loop at some point in its iteration? that what
the "break" statement is for, no? I'm just interested in knowing if the
Framework designers exposed the ability to do so with high-level iterative
controls like Repeater and DataList ... personally, I think they should
have ... I don't particularly like the idea of iteration being exclusively
determined by the characteristics of another object ... but that's just my
two cents ..
I expected to see something like this possibility in the dataBound
handler:
e.CancelIteration="true";
guess not .... I suppose I could write my own Repeater control ... but
I'd rather not ....
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
Barrie Wilson said:
message Well, the eventhandler returns void, so have you tried:
if (myRowCount > 200)
{
return ;
}
no, that doesn't stop the iteration ..
--Actually I think it might be a lot cleaner if you just modified the
datasource prior to databinding.
I'm not clear what you mean here; modify it how and when? before
binding the DataList or before binding the row? suppose I only want to
return N rows contingent upon some arbitrary condition ? how would I
modify the datasource in mid-stream? suppose, for example, we display
no more data if an accumulator exceeds a certain value ...
in any case, in this instance the datasource is a method which returns
an array : DirectoryInfo.GetFiles() ... so I don't know how I would
modify it in any meaningful way ... I suppose there's a way to
essentially put some smarts into that method .... but really I was
interested in knowing whether there was simply a way to terminate
iteration ...
thanks for your reply ..
BW