tooltip for each row in grid view

P

puja

hi all,

i have a grid view where am displaying data from dataset. My dataset
consists of columns Customer name, surname, date requested, sales person,
file number , status and comments
I am displaying all columns in grid view except comments.

Now I want to have comments displayed (for each row) as tooltip when u hover
over particular row.

Does anybody know the code for this ?

thanks
puja
 
S

Scott Woods

I've done it with a Web datagrid. The grid has a value column that's
hidden and a button that's visible. If the value column is empty it
shows the button. If the value is there it shows who pressed the button
and the tooltip is shown if notes were attached. In the ItemDataBound
event I get the underlying data to use to make desicions. I create a
label control on the fly and use it's ToolTip to show the tooltip. I
also wanted a different cursor so that's there also.



private void dgBids_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if((e.Item.ItemType.ToString() == "Item" || e.Item.ItemType.ToString()
== "AlternatingItem") || e.Item.ItemType.ToString() == "EditItem")
{
DataRowView drv = (DataRowView)e.Item.DataItem;
string sRejected = e.Item.Cells[5].Text.Trim().Replace(" ","");
Button btnDis = (Button)e.Item.Cells[6].Controls[0];
if(sRejected.Length == 0 || sRejected.Equals("0"))
{
btnApp.Visible = false;
Label lb = new Label();
lb.Text = "Appr. by " + drv.Row["Approver"].ToString();
string tt = drv.Row["SupervisorNotes"].ToString();
if(tt.Length)
{
lb.ToolTip = tt;
lb.Style.Add("cursor","url('comment.cur')");
}
e.Item.Cells[4].Controls.Add(lb);
}
}
}



Hope that Helps
 
S

Scott Woods

Sorry, I forgot. If you want to just deal with mouseover on the TR
(row) Dino Esposito has a great article about using CSS behaviors to get
a rowover type highlight. It does require you override the datagrid in
NET 1.1, but his examples help a lot to understand what you can do with
behaviors.

http://msdn.microsoft.com/msdnmag/issues/05/03/CuttingEdge/

Again, hoping this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top