请问,怎样用把一个变量设成一个控件的属性值?
请问,怎样用把一个变量设成一个控件的属性值?
如: <asp:AccessDataSource ID= "AccessDataSource2 " runat= "server " DataFile= "~/App_Data/access/报表.mdb "
selectcommand= "select * from [电话簿] "> </asp:AccessDataSource> 我想用一个变量来替换 "select * from [电话簿] "可以吗?怎么替换?
------解决方案--------------------: <asp:AccessDataSource ID= "AccessDataSource2 " runat= "server " DataFile= "~/App_Data/access/报表.mdb "
selectcommand= ' <%=StrSql%> '> </asp:AccessDataSource>
==============================
后台:
=====
private string _StrSql;
public string StrSql
{
get
{
return _StrSql;
}
}
.....
if(!Page.IsPostBack)
{
_StrSql = "select * from [电话簿] ";
}