Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need gridview rownumber / mouseover help !!!!

    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
    Last edited by hedager; 08-06-2011 at 09:28 AM.

  • #2
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    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

  • #3
    New Coder
    Join Date
    Aug 2011
    Posts
    50
    Thanks
    0
    Thanked 2 Times in 2 Posts

    catch gridview row number on mouse over

    Try the following code :

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •