473,320 Members | 1,724 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,320 software developers and data experts.

how to implement tooltip

Hello

I am using a tooltip in one of my column in datagrid.
I want to show only 1st 20 characters and rest of the text to be shown in tooltip .
for this i need to write a function.

here is my code

Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField HeaderText="CommentText">
  2.                <ItemTemplate>
  3.                 <asp:Labelid="lbl"text='<%#tooltip(System.Convert.ToString(Eval("CommentText"))) %>' runat="server" ToolTip='<%#Eval("CommentText") %>'></asp:Label>
  4.                </ItemTemplate>
  5.                  </asp:TemplateField>  
  6.  
Expand|Select|Wrap|Line Numbers
  1. public string tooltip(String input)//function is to display only 1st 20characters
  2. {      
  3.         char[] delimiterChars = { ' ' };
  4.         string[] words = input.Split(delimiterChars);
  5.  
  6.             string output = "";
  7.             //rebuilds string without new word
  8.             for (int x = 0; x != 20; x++)
  9.             {
  10.                 if (x == 0)
  11.                 {
  12.                     output = words[x].ToString();
  13.                 }
  14.                 else
  15.                 {
  16.                     output = output+" "+words[x];
  17.                 }
  18.             }
  19.  
  20.         return output;
  21.     }
I am not sure whether my function is correct or not.
I am getting error
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Expand|Select|Wrap|Line Numbers
  1. Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.
  2.  
  3. Source Error:
  4.  
  5. Line 31:                 else
  6. Line 32:                 {
  7. Line 33:                     output = output+" "+words[x];
  8. Line 34:                 }
  9. Line 35:             }
please help

Thank You
Oct 10 '08 #1
2 1470
Curtis Rutland
3,256 Expert 2GB
Please use [code] tags when posting code.

Mod.
Oct 10 '08 #2
tlhintoq
3,525 Expert 2GB
There is no real reason to do the elaborate if...else of lines 6-17.
If the string 'output' is initialized to "" or string output = string.empty; either one it is still perfectly acceptable to += your next item to it.

There is no range checking taking place.
If your words[x] array only has 5 words, but you still try to take word number 17 out of it you would expect an error.
Oct 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Yves Royer | last post by:
Hi, I'm currently writing an application (in VS 2005 bèta 2) and made some own user controls. In each user control I added a ToolTip object so i can set some tooltips on checkboxes etc. What...
0
by: Yves Royer | last post by:
Hi, My first post didn't show up so here's a second try. I'm currently writing an application (in VS 2005 bèta 2) and made some own user controls. In each user control I added a ToolTip object...
6
by: ltt19 | last post by:
HI everyone, So, I have many buttons, and all of them must show a tooltip with the same string, except one word, that I must read this owrd from a variable. Although, the "ToolTip on x" property...
0
by: Prakash | last post by:
Hi Friends, I am developing scheduler application using C#. In my application i have provide the list view control for displaying the scheduled items. The listview control having the following...
8
by: GS | last post by:
Guys: I have a question, Is it possible to implement pop-up window without Java script, we don't want to use java script since it might get blocked by pop-up blocker. Thanks in advance. GS.
5
by: =?Utf-8?B?cGV0ZTE5Njk=?= | last post by:
I use Visual Studio 2005 and created a very simple Form with one button. I added a Tooltip for that button. It shows fine the first time I hover over that button. But if I let it disappear by the...
6
by: john | last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows; I'm using Visual Studio 2008 VB: <asp:TextBox ID="txtDay1" runat="server" Text='<%# Eval("Day1") %>'...
3
omerbutt
by: omerbutt | last post by:
hi there i have downloaded a prototype tooltip from http://www.nickstakenburg.com/projects/prototip/ the logic it uses is to call the script after creating the <div> for example i am using the...
16
by: Charles Law | last post by:
I have to take this personally now. Tooltips have been flakey since the dawn of .NET, but to still have to put up with a disappearing tooltip in VS 2008 is getting beyond a joke. Tooltips have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.