62,267
社区成员
发帖
与我相关
我的任务
分享
protected override void Render(HtmlTextWriter output)
{
string DDLValue;
string DDLText;
output.Write("<div class=\"ui-widget\">");
_ddlSource = (DataTable)ViewState["AutoListDataSource"];
_valueKeyName = (string)ViewState["AutoListValueKeyName"];
_textKeyName = (string)ViewState["AutoListTextKeyName"];
_isShowDetailed = (bool)ViewState["AutoListShowDetailed"];
if (_ddlSource != null)
{
if (_ddlSource.Rows.Count > 0)
{
foreach (DataRow dr in _ddlSource.Rows)
{
DDLValue = String.IsNullOrEmpty(_valueKeyName) == true ? dr[0].ToString() : dr[_valueKeyName].ToString();
DDLText = String.IsNullOrEmpty(_textKeyName) == true ? dr[1].ToString() : dr[_textKeyName].ToString();
ListItem li = new ListItem();
if (_isShowDetailed == true)
{
li.Text = DDLValue + "|" + DDLText;
}
else
{
li.Text = DDLValue;
}
li.Value = DDLValue;
this.Items.Add(li);
}
}
if (this.Items.Count > 0)
{
this.Items.Insert(0, new ListItem("", ""));
}
if (ViewState["AutoListSelectValue"] != null)
{
this.Items.FindByValue((string)ViewState["AutoListSelectValue"]).Selected = true;
}
}
base.Render(output);
output.Write("</div>");
}
public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
string[] postDataValues = postCollection.GetValues(postDataKey);
if (postDataValues != null)
{
this.SelectedValue = postDataValues[0];
if (this.SelectedValue != null && (postDataValues[0] != null && !this.SelectedValue.Equals(postDataValues[0])))
{
this.SelectedValue = postDataValues[0];
ViewState["AutoListSelectValue"] = this.SelectedValue;
return true;
}
}
else
{
return false;
}
return false;
}