Instead of applying conditional logic to generate the HTML (sphagetti
code), it would be better to apply conditions to generate the
datasource itself based on which you can simply the data control.

In other words, put those records into a datasource (e.g., datatable)
that are required to be shown. Then bind the data control (e.g.,
Repeater) to that datasource.

On Oct 30, 3:58 am, KR <[email protected]> wrote:
> Hi -
>
> I have a web page that has a SqlDataSource in it.  What I want to do
> is create a bunch of DIVs on the page depending on the records
> returned from the query.  Sometimes I want to group 4 records
> together:
>
> <div>
>   <div >
>      record 1 contents
>   </div>
>   <div>
>      record 2 contents
>   </div>
> ...
> <.div>
>
> and sometimes I want to group 6 records together in the same fashion.
>
> A simple repeater doesn't seem to do what I want because that expects
> 1 homogeneous dom element per record.
>
> My big question is, how do interject script logic into the page and
> then how do, inside a function, create DOM elements.
>
> So what I want to do is something like this:
>
> <html>
> <head>
> ...
> </head>
> <body>
> <SqlDataAdapter goes here>
> < ... put a script here that says something like this >
> recordindex = 0
> while record index < total number of records
>   read first record, if field 1 == "A" then read the next 4 records
> and with those 4 records do this:
>   put "<div> record #1 data here </div>" into the DOM
>   ..same for next 3 records
> else do this:
>   put "<div> record #1 data here </div>" into the DOM
>   ..same for next 5 records
> end
> recordindex += 4 or 6 depending on which path was chosen
> end while
>
> What I can't figure out is, how do I write to the DOM inside a server
> script?
>
> i.e.
>
> how do I write a function that says "put this HTML here" ?
>
> Thanks for any help.
> K.

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to