Solution:
Add a
ondatabound
event handler to your DropDownList control:<asp:DropDownList runat="server"Then implement handler:
DataSourceId="MyCustomDatasource"
DataTextField="SomeName"
DataValueField="SomeValueCode"
ondatabound="ApplyOptionTitles"
... />
protected void ApplyOptionTitles(object sender, EventArgs e)Answer found here.
{
DropDownList ddl = sender as DropDownList;
if (ddl != null)
{
foreach (ListItem item in ddl.Items)
{
item.Attributes["title"] = item.Text;
}
}
}
3 comments:
great stuff, but i want to disable item in dropdownlist. How to do it?
http://tatca.vn
http://taphop.net
It should be as simple as that:
item.Attributes["disabled"] = true;
Good articale
Post a Comment