Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 02, 2012 02:48 AM by navanathdivate
Member
11 Points
26 Posts
May 01, 2012 05:01 AM|LINK
Hi ,
i know how we can set tooltip for dropdonlist from it's list item but i'm facing with some differnt issue
My database structure is like below..
Table Name: MachineUtilization
Sr.No CODE Problem
1 A No Tooling
2 B No Loading
3 C No power
4 D No Operator
5 E Break Down
////////////////////////////////////////
I Fetch first column as list item in the dropdownlist .
I want to set tooltip for these list item from "Problem" column of the Table
like when i move mouse over A ,B,C ... List item then it will show the corresponding proble as tooltip whether it is possible or not
A--(tooltip)No Tooling
B --(tooltip)No Load
198 Points
51 Posts
May 01, 2012 06:12 AM|LINK
Are you looking for dynamic tooltip
check this link http://stackoverflow.com/questions/3984822/binded-dropdownlist-with-tooltip
All-Star
95413 Points
14106 Posts
May 01, 2012 06:18 AM|LINK
what you can do is to iterate Dropdownlist.Items and then for each listitem add Attribute "Title" with its corresponding value from Database...something like shown here - http://weblogs.asp.net/abdullaabdelhaq/archive/2009/06/07/adding-tooltip-for-each-list-item.aspx
Thanks,
6 Points
11 Posts
May 01, 2012 06:19 AM|LINK
take dropdownlist
and write this code
SqlDataAdapter da = new SqlDataAdapter("select * from test1", con); DataTable dt = new DataTable(); da.Fill(dt); DropDownList1.DataSource = dt; DropDownList1.DataTextField = "code"; DropDownList1.DataValueField = "sr"; DropDownList1.DataBind(); for(int i=0; i<= DropDownList1.Items.Count-1; i++) { DropDownList1.Items[i].Attributes.Add("Title", dt.Rows[i]["problem"].ToString()); }
Plz Marks As Answer
one thing u can check also using different browser. mozilla is better.
May 01, 2012 07:33 AM|LINK
but my Dropdownlist is bound in Gridview so how can i perform above operation
Gridview
//////////////
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource2" Width="449px" AllowPaging="True">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="id" HeaderText="ID" SortExpression="id" />
<asp:BoundField DataField="machine" HeaderText="Machine" SortExpression="machine" />
<asp:TemplateField HeaderText="SHIFT-1" InsertVisible="False" SortExpression="id">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("code") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="CODE" DataValueField="CODE">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SHIFT-2" InsertVisible="False" SortExpression="id">
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1" DataTextField="CODE" DataValueField="CODE">
</Columns>
</asp:GridView>
484 Points
216 Posts
May 01, 2012 09:47 AM|LINK
Hi,
try this
<asp:DropDownList ID="ddlDetails" runat="server" ondatabound="ddlDetails_DataBound"/>
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { BindDropdown(); } } protected void BindDropdown() { SqlConnection con =new SqlConnection("Data Source=Changetoyours;Initial Catalog=MySampleDB;Integrated Security=true"); 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; } } } }
May 02, 2012 02:48 AM|LINK
I got error at line ::
//////////////////////////
ddlDetails.DataTextField = "UserName";
ddlDetails.DataValueField = "UserId";
ddlDetails.DataSource = ds;
ddlDetails.DataBind();
////////////////////////
the error is ::ddlDetails is not declared.It may be inaccesible due to it's protection level.
I tried lot top remove this error ut i couldn't resolve it.
so can you tell me why it gave me this error i ckecked
both dropdonlist ID in design view and code view are same so why i can't i access design view dropdownlist id in code view...
navanathdiva...
Member
11 Points
26 Posts
Tooltip for Dropdownlist
May 01, 2012 05:01 AM|LINK
Hi ,
i know how we can set tooltip for dropdonlist from it's list item but i'm facing with some differnt issue
My database structure is like below..
Table Name: MachineUtilization
Sr.No CODE Problem
1 A No Tooling
2 B No Loading
3 C No power
4 D No Operator
5 E Break Down
////////////////////////////////////////
I Fetch first column as list item in the dropdownlist .
I want to set tooltip for these list item from "Problem" column of the Table
like when i move mouse over A ,B,C ... List item then it will show the corresponding proble as tooltip whether it is possible or not
A--(tooltip)No Tooling
B --(tooltip)No Load
praseTech
Member
198 Points
51 Posts
Re: Tooltip for Dropdownlist
May 01, 2012 06:12 AM|LINK
Are you looking for dynamic tooltip
check this link http://stackoverflow.com/questions/3984822/binded-dropdownlist-with-tooltip
ramiramilu
All-Star
95413 Points
14106 Posts
Re: Tooltip for Dropdownlist
May 01, 2012 06:18 AM|LINK
what you can do is to iterate Dropdownlist.Items and then for each listitem add Attribute "Title" with its corresponding value from Database...something like shown here - http://weblogs.asp.net/abdullaabdelhaq/archive/2009/06/07/adding-tooltip-for-each-list-item.aspx
Thanks,
JumpStart
Akhand Prata...
Member
6 Points
11 Posts
Re: Tooltip for Dropdownlist
May 01, 2012 06:19 AM|LINK
take dropdownlist
and write this code
SqlDataAdapter da = new SqlDataAdapter("select * from test1", con);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "code";
DropDownList1.DataValueField = "sr";
DropDownList1.DataBind();
for(int i=0; i<= DropDownList1.Items.Count-1; i++)
{
DropDownList1.Items[i].Attributes.Add("Title", dt.Rows[i]["problem"].ToString());
}
Plz Marks As Answer
one thing u can check also using different browser. mozilla is better.
navanathdiva...
Member
11 Points
26 Posts
Re: Tooltip for Dropdownlist
May 01, 2012 07:33 AM|LINK
but my Dropdownlist is bound in Gridview so how can i perform above operation
Gridview
//////////////
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource2" Width="449px" AllowPaging="True">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="id" HeaderText="ID" SortExpression="id" />
<asp:BoundField DataField="machine" HeaderText="Machine" SortExpression="machine" />
<asp:TemplateField HeaderText="SHIFT-1" InsertVisible="False" SortExpression="id">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("code") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="CODE" DataValueField="CODE">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SHIFT-2" InsertVisible="False" SortExpression="id">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("code") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1" DataTextField="CODE" DataValueField="CODE">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
vikramchowda...
Member
484 Points
216 Posts
Re: Tooltip for Dropdownlist
May 01, 2012 09:47 AM|LINK
Hi,
try this
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { BindDropdown(); } } protected void BindDropdown() { SqlConnection con =new SqlConnection("Data Source=Changetoyours;Initial Catalog=MySampleDB;Integrated Security=true"); 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; } } } }Sincerely,
Vikram
navanathdiva...
Member
11 Points
26 Posts
Re: Tooltip for Dropdownlist
May 02, 2012 02:48 AM|LINK
I got error at line ::
//////////////////////////
ddlDetails.DataTextField = "UserName";
ddlDetails.DataValueField = "UserId";
ddlDetails.DataSource = ds;
ddlDetails.DataBind();
////////////////////////
the error is ::ddlDetails is not declared.It may be inaccesible due to it's protection level.
I tried lot top remove this error ut i couldn't resolve it.
so can you tell me why it gave me this error i ckecked
both dropdonlist ID in design view and code view are same so why i can't i access design view dropdownlist id in code view...