On mouse over event show tooltip dropdownlist items by using C# example

Use tooltip in Asp.net dropdownlist items by mouse over event with Example using C#:



Asp.net  with C# Dropdownlist Related Post:



Display ToolTip of Dropdownlist control:

Now in this post we take a Example that consider how to display data as tooltip in C# of each item of list.

Code of dropdownlist data bound method:
protected void myddlist_DataBound(object sender, EventArgs e)
    {
        DropDownList ddl = sender as DropDownList;
        if (ddl != null)
        {
            foreach (ListItem li in ddl.Items)
            {
                li.Attributes["title"] = li.Text;
            }
        }
    }
 
Show tooltip dropdownlist items by mouseoverevent
Show tooltip dropdownlist items by mouseoverevent
Use Tooltip on dropdownlist control each item C# code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class DropDownlistItemtooltip : System.Web.UI.Page
{
    string _connectionstring;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            _connectionstring = @"Data Source=PARIJAT-PC\PARIJAT;Initial Catalog=Database1;Integrated Security=True;Pooling=False";
            BindData();
        }
    }

    protected void BindData()
    {


        string _sql = "select StateID,StateName from States";
        SqlConnection _connection = new SqlConnection(_connectionstring);
        SqlCommand _command = new SqlCommand(_sql, _connection);
        SqlDataAdapter _adapter = new SqlDataAdapter(_command);
        DataTable datatable = new DataTable();
        _adapter.Fill(datatable);
        myddlist.DataTextField = "StateName";
        myddlist.DataValueField = "StateID";
        myddlist.DataSource = datatable;
        myddlist.DataBind();
    }
    protected void myddlist_DataBound(object sender, EventArgs e)
    {
        DropDownList ddl = sender as DropDownList;
        if (ddl != null)
        {
            foreach (ListItem li in ddl.Items)
            {
                li.Attributes["title"] = li.Text;
            }
        }
    }
    protected void myddlist_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}




Other Asp.net Related Post :


Comments

  1. Hello. Anything about an automatic dropdown to convert a bootstrap navbar from onclick to hover?

    ReplyDelete

Post a Comment