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

Thursday, August 21, 2014

Display tooltip from database for dropdownlist items in c# example

Example of Display tooltip from database for dropdownlist items in c#

In this post we describe a Example for display tooltip in dropdownlist each item in  And the importance of Tooltip is in web development we can use long length world in dropdown list in name field.  In this Programming tutorial we consider a post how to show tool tip of dropdownlist item on mouseover event and  many Examples that’s refers to dropdown list, these are listed here each have relation to dropdownlist example: Dropdownlist Related Post:

Display ToolTip for Dropdown List:
Now in this post we take an example and display data as tooltip of each item of list.

Example of use tooltip in dropdownlist in c#:

Take a sql database table and bind dropdownlist. Then create dropdownlist  DataBound Method and using this bind name to tooltip. Here we give the code for solving this in using C#.

Show Tooltip Example of dropdownlist item code :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropDownlistItemtooltip.aspx.cs" Inherits="DropDownlistItemtooltip" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head id="PageHead1" runat="server">
    <style type="text/css">

<form id="form1" runat="server">
<div align="center">
    <br />
<h2> Display tooltip from database for dropdownlist items Example</h2>
    <p><strong>Select State for this dropdownlist </strong></p>
    <br />
    <br />
<asp:DropDownList ID="myddlist" runat="server" ondatabound="myddlist_DataBound"  onselectedindexchanged="myddlist_SelectedIndexChanged"/>

Use Tooltip on dropdownlist  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";

    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();
        myddlist.DataTextField = "StateName";
        myddlist.DataValueField = "StateID";
        myddlist.DataSource = datatable;
    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 Related Post :

No comments:

Post a Comment