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#:
In this post we describe
how to create tooltip in dropdownlist each item inasp.net with C# programming. In the past post we take example for displaying tooltip of dropdownlist item and one other is how to add tooltip ineach item of dropdownlist.
Asp.net with C# Dropdownlist Related Post:
- Check box in asp Dropdownlist Example.
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;
}
}
}
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 :
- Example of Events in asp.net
Hello. Anything about an automatic dropdown to convert a bootstrap navbar from onclick to hover?
ReplyDelete