[英]Passing values to html select from code behind
I have an html select in one of my aspx pages and I would like to assign it the option value from code behind. 我在一个aspx页面中有一个html select,我想从后面的代码中为其分配选项值。
<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?. 我有一个类型为int的属性调用
MyPageCount
,如何在此处传递其值?
I would appreciate any help. 我将不胜感激任何帮助。
Regards 问候
add runat="server"
and then set pageSize.Value=MyPageCount;
添加
runat="server"
,然后设置pageSize.Value=MyPageCount;
in codebehind 在代码背后
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.