views:

25

answers:

1

Hi

I am using one DataGrid with templatecolumn of Asp:Label Control. In Design Page i used Tool tip for this control, But in the ItemDatabound event, it will checks the number of characters of the text of this label. If the character is less than 40, i have to disable the tooltip for that control only.. But i couldn't finalize this task. How it will be done? Please help me. Thanks in advance..

+2  A: 

Assuming the label is the first cell in the DataGrid. If not, you'll need to change the number in Cells[0].

  void R1_ItemDataBound(Object sender, DataGridItemEventArgs e)
  {

      if (e.Item.ItemType == ListItemType.Item || 
          e.Item.ItemType == ListItemType.AlternatingItem) 
         {

             if(e.Item.Cells[0].Text.Length <= 40){
                 e.Item.Cells[0].Text = String.Empty;
             }
         }
  }
David Neale