user123
user123

Reputation: 61

how to use repeater data inside style tag in asp

I am using repeater control to get average rating from database and I want to use that average rating inside style tag for width..

I am using the code as: style="height:15px; width:'" & <%# Eval(Container,"DataItem.AverageRating")"' %>" but it is giving an error "tag not well formed" please tell..

Upvotes: 0

Views: 339

Answers (2)

asharajay
asharajay

Reputation: 1193

you can use this its worked for me

style='<%#"height:15px; width:" + Eval(Container,"DataItem.AverageRating").ToString() +"px;"'

Upvotes: 2

Chris Marais
Chris Marais

Reputation: 411

one way is you can make a method in your code-behind that will return a string e.g

<input <%# WriteWidth( Eval(Container,"DataItem.AverageRating").ToString() ) %>

then in the code-behind:

protected string WriteWidth(string Width)
{
 return string.format(" style='height: 15px, width: {0}px'", Width);
}

Upvotes: 0

Related Questions