...

View Full Version : Need gridview rownumber / mouseover help !!!!



hedager
08-06-2011, 08:21 AM
Hi all,

I have a gridview ( gridview1 ) with name and phonenumbers of various people. On my form i also have formview ( formview1 ). Now what i want to achieve is that when the user move the mouse over the gridview the formview should show additional data like work, adress etc.

I hope to achieve this without clicking in the gridview.

My primary key in the database is always in the first column of the gridview.

I have tried to make some Javascript to get the rownumber under the mouse, but i am not very familiar with javascript - so it didnt work for me.

I have also posted in the javascript part of this website but nobody seems to answer ( maybe it cant be done ).

I guess if i can just get the rownumber under the mouse during the gridview1_rowcreated part i can make some additional coding to make the query to the database.

Does any of you know how to achieve this or does any of you know another way to make the mouseover / show additional data.

I am coding the page in VB

Thank you

Mourya
08-14-2011, 02:58 PM
Hi,

First of all include the FormView in the gridview ItemTemplate and use style="display:none" property to hide the FormView , which you need to show whenever onmouseover event is fired.


I suggested that you add the javascript onmouseover event for each row of the
GridView.

This can be acheived by using RowDataBound event ,
protected void gvplot_RowDataBound(object sender, GridViewRowEventArgs e)

{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// then use this code to find the FormView control
FormView formview1 = (FormView)e.Row.FindControl("formview1");

// then add the onmouseover event to the row.
e.Row.Attributes("onmouseover", "javascript:show_details(" + formview1.ClientID + ")");
}

}



JAVAScript Function:

function show_details(formview1)
{
// Here we are displaying the formview
formview1.style.display='inline';

}


-- Mourya

dotnetmind
08-18-2011, 07:54 PM
Try the following code :


Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onmouseover", String.Format("alert('{0}');", e.Row.RowIndex))
End If
End Sub



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum