Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Thursday, August 21, 2014

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 :


1 comment:

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

    ReplyDelete