473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Displaying a tooltip in a datagrid cell, tough problem, can it be

I'm trying to work with a datagrid column in order to display a tooltip in a
datagrid cell. The reason I am doing this is because I have some long strings
being returned and I don't want the rows of the datagrid expaning down to
much. I basically want to display the first 50 characters in the grid cell
and then display the rest as a tooltip in the grid cell. I'm not sure if this
is possible but if anyone can help me do this I would be very grateful. I
have started this and am able to do the first part and get only the first 50
characters to be displayed back. I can also get the rest of the string set to
a new variable but I don't know how to use this properly and display a
tooltip with the string value for only that cell. Hope everyone knows what
i'm trying to do and that i've explained myself well enough. I've included
the code to show what I've down and also to give an idea of what i'm trying
to do. Any help at all would be very much appreciated.

HTML for the Column
<asp:TemplateColumn Visible="True" HeaderText="Start Date">
<ItemTemplate>
<%#getCompanyName(DataBinder.Eval(Container.DataIt em,"CompanyName").ToString())%>
</ItemTemplate>
</asp:TemplateColumn>

Code Behind with comments of what I need to do

public string getCompanyName(string p_sFieldValue )
{
int iLength = p_sFieldValue.Length;
int iLengthToUse = 0;
int iRemainder = 0;

if (p_sFieldValue == DBNull.Value.ToString())
{
return string.Empty;
}
else if(iLength > 50)
{
//In here I basically would like to only return the first
//50 characters of the string and then for the rest of the
//string I’d like the details to be displayed in a tooltip
//for that cell. I know the below code won’t work because
//of the e but its just to give an idea of what I need to do.
//If someone knows how I can display a tooltip for the rest
//of the string I’d be really really grateful
//I’m not sure if this can be done but if anyone has any
//ideas I’d really appreciate it. Thanks
/*
iRemainder = p_sFieldValue.Length - 50;
string sTooltipText = p_sFieldValue.Substring(50,iRemainder);
if(e.Item.ItemType == ListItemType. SelectedItem)
{
e.Item.Cells[1].ToolTip = sTooltipText;
}
*/
//This bit works fine
string sCompanyName = p_sFieldValue.Substring(0,50); return
sCompanyName;
}
else
{
return p_sFieldValue;
}
}

Jul 21 '05 #1
2 1830
<ItemTempalte>
<span title="<%# full_text" %>"><%# partial_text %></span>
</ItemTemplate>

HTH

CHeers,
Gaurav Vaish
http://mastergaurav.org
http://mastergaurav.blogspot.com
----------------------------

Jul 21 '05 #2
Cheers what is it that this does exactly and do you know how I can use this
to display the tooltip. I do see where your coming from here though. How do I
bind to the column though. Do I remove the following or do I keep it in: -
(DataBinder.Eval(Container.DataItem,"CompanyName") .ToString())

Sorry for all the questions I'm just really stuck on this one.
Thanks again for your input.

"MasterGaurav" wrote:
<ItemTempalte>
<span title="<%# full_text" %>"><%# partial_text %></span>
</ItemTemplate>

HTH

CHeers,
Gaurav Vaish
http://mastergaurav.org
http://mastergaurav.blogspot.com
----------------------------

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephen | last post by:
I have the following column and so far im able to bind the column to CompanyName and only return the first 50 characters. The second function i'd like to retun a tooltip for that datagrid cell but...
4
by: JerryP | last post by:
Hi Group, Id like to have a tooltip for each col in the datagrid. Is there a way to do that ? Thanks ! Jerry
2
by: Stephen | last post by:
Is it possible to add a tooltip in the column of a Datagrid. Can someone please show me how I would do this for the datagrid column below. Thanks for any help anyone can give me. Here is the...
1
by: Lars Netzel | last post by:
I need to have a Tooltip on each Cell in a datagrid, I don't know how to do this. I'm using Styles to the datagrid (Which I asume most people do since you never need to show all the fields from the...
3
by: Craig G | last post by:
what way do you code it? i tried the following but it wouldnt display it lblAdd_info is a hidden field in the cell itself that contains the data i want to display in the tooltip text. i added the...
5
by: Lars Netzel | last post by:
I need to have a Tooltip on each Cell in a datagrid, I don't know how to do this. I'm using Styles to the datagrid (Which I asume most people do since you never need to show all the fields from the...
2
by: james | last post by:
I have been looking for a way to reproduce the tooltip that Access displays when scrolling the Datagrid that shows the record count (changes as you move the thumb up or down). So far, nothing I...
2
by: Stephen | last post by:
I'm trying to work with a datagrid column in order to display a tooltip in a datagrid cell. The reason I am doing this is because I have some long strings being returned and I don't want the rows...
2
by: geronimi | last post by:
I want a tooltip (in an item in a datagrid) to stay for more then 5 seconds (standard) visible, Do I have to write my own Toolip or can I change a setting somewhere to increase the tooltip visible...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.