本文介绍了asp.net下拉列表的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How to Create a tooltip for Dropdownlist each Items it's Work on with Using Mouse.

plase any one can help me

推荐答案

public void Tooltip(ListControl lc)
{
    for (int d = 0; d < lc.Items.Count; d++)
    {
        lc.Items[d].Attributes.Add("title", lc.Items[d].Text);
    }
}







试试这个链接 -

[]


 protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindDropdown();
}
}
protected void BindDropdown()
{
SqlConnection con =new SqlConnection("your connection string ");
con.Open();
SqlCommand cmd = new SqlCommand("select UserId,UserName from UserInformation", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ddlDetails.DataTextField = "UserName";
ddlDetails.DataValueField = "UserId";
ddlDetails.DataSource = ds;
ddlDetails.DataBind();
}
protected void ddlDetails_DataBound(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
if(ddl!=null)
{
foreach (ListItem li in ddl.Items)
{
li.Attributes["title"] = li.Text;
} 
}
}
}


这篇关于asp.net下拉列表的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 12:09