rob*_*nal 2 c# asp.net drop-down-menu
嗨我有一个从后面的代码限制的DropDownList.如何使用DataTextFieldDropDownList的工具提示?
DropDownList list = this.DropDownList1;
list.DataSource = GetData();
list.DataTextField = "DisplayString";
list.DataValueField = "DataValue";
list.DataBind();
Run Code Online (Sandbox Code Playgroud)
我希望有界Field DisplayString也可以在ToolTip中界定.如果不使用DataBoundDropDownList 的事件,这可能吗?
小智 8
只需在下拉列表绑定后调用该函数: BindTooltip(Name of the dropdownlist);
public void BindTooltip(ListControl lc)
{
for (int i = 0; i < lc.Items.Count; i++)
{
lc.Items[i].Attributes.Add("title", lc.Items[i].Text);
}
}
Run Code Online (Sandbox Code Playgroud)