Reputation: 11469
I have an html select in one of my aspx pages and I would like to assign it the option value from code behind.
<select id="pageSize" runat="Server">
<option value="how to set it from c#?">All</option>
I have a property call MyPageCount
of type int, how can i pass its value here?.
I would appreciate any help.
Regards
Upvotes: 2
Views: 2638
Reputation: 8337
add runat="server"
and then set pageSize.Value=MyPageCount;
in codebehind
Upvotes: 1
Reputation: 21365
Have you tried this:
<option value="<%: this.MyPageCount.ToString() %>">All</option>
If it's inside a data bound control:
<option value='<%# Bind("YourField") %>'>All</option>
Upvotes: 0