How to change id values on a control while looping through.
I'm trying to add a hot news section with the TOP 3 results from the database into rounded edged tables. What I want to do is change the id value so it is not the same for each one. What I tried to do is add an incremented integer value at the end of "RoundedCorners1" with n being the incremented integer value and the tags looked like this:
<% Response.Write("id=RoundedCorners1" & n) %>
The problem is, I get an error saying that I cannot do this within a control. How would I go about changing the id value each time I loop through?
Here's the code
<skm:roundedcorners id="RoundedCorners1" runat="server" BackgroundBackColor="white"
BackColor="#FFE0C0" BorderColor="Black" BorderStyle="Solid"
Width="150px" Padding="1px" CornerHeight="16px" TextHorizontalAlign="Center">
This is a simple example with text in the rounded corners box. It has a width
explicitly set to 150 pixels, and the images are anti-aliased.
You don't need to do all of that. Just when you are looping it write the contents out in a div with a different class each time, like class1, class2, and then style that class differently with css. Let the browser read the css. You do not need to change any ids.
If it's possible, could you give me an example of what it might look like? What I increment the CSS div each time or set it statically?
When you write it out, with a repeater or loop or whatever, you just swap out the value of the class, like you write out the variable and that would be a number 1 or 2 or something, then you have a class 1 or 2, and it gets the data from that. But you really do not have to change anything in the data base, you just change the value when the result is written out. If you use a repeater you can even use alternating item template etc so every other item gets a different template. Repeaters are by far the most efficient / stream lined way to write out data while giving the developer a ton of design control.
I was able to use a repeater to do it and it worked. I'm new to repeaters that is why I didn't use them in the first place. Thanks for your help.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)