如何在页面回发后设置用户控件的属性。
public void GetData()
{
_GetSelectValue = ClassListID。选择的值;
ClassListID。items . Clear();
字符串Sql
if (Cache["ClassID"]!= null & amp& amp缓存["ClassID"]。ToString()!= "")
{
SQL = " SELECT * FROM project class WHERE project class。类似“%”+Cache[" ClassID "]的ParentPath。ToString() +",% '或ParentID = " + Cache["ClassID"]。ToString() + " ORDER BY RootID,OrderID ";
}
其他
{
SQL = " SELECT * FROM project class ORDER BY RootID,OrderID ";
}
SqlDataReader dr = SqlHelper。ExecuteReader(SqlHelper。ConnectionString,CommandTypeText,Sql);
如果(!_启用)
{
ClassListID。Attributes.Add("disabled "," disabled ");
}
if (_IsList)
{
ClassListID。Attributes.Add("size "," 20 ");
ClassListID。Style.Add(HtmlTextWriterStyle。宽度,“280像素”);
}
if (_ShowFirst)
{
ClassListID。items . Add(new ListItem(_ first text,“0”);
}
while (dr.Read())
{
string Nbsp = null//带空格的变量;
string optionText = null
如果(转换。toint 16(dr[" ParentID "])= = 0)
{
optionText = HttpUtility。html decode(" "+dr[" class name "];
}
其他
{
int STM_Path = Convert。ToInt16(dr["深度"]);//如果ParentID不为0,说明不是根元素,搞清楚是哪一层;
for(int I = 0;我& ltSTM _ Pathi++)
{
//每层加4个空格;
Nbsp += HttpUtility。html decode(" ");
}
option text = nbsp+"├"+dr[" class name "];
}
ClassListID。Items.Add(新的ListItem(optionText,dr["ClassID"])。ToString()));
}
Close博士();
dr . Dispose();
}
受保护的void Page_Load(对象发送方,EventArgs e)
{
如果(!IsPostBack)
{
get data();
ClassListID。SelectedValue = _ SetSelectValue
}
}
然后在页面的按钮事件中:
受保护的void Button1_Click(对象发送方,EventArgs e)
{
ClassID。IsList = true
ClassID。get data();
}