Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have this code in JavaScript with asp.net

I use Right Click Menu and it Work done but i need to get index selected row to use

in code behind in my project

this my code :
JavaScript
<pre><script type="text/javascript" src="JS/ContextMenu.js"></script>

<script type="text/javascript">
var oCustomContextMenu = null;
    var oBase = null; 


   var Thevalue= null; 
window.onload = function()
{
    oBase = document.getElementById("GridView1");


    var Arguments = {
        Base: oBase,
        Width: 200,
        FontColor: null,
        HoverFontColor: null,
        HoverBackgroundColor: null,
        HoverBorderColor: null,
        ClickEventListener: OnClick
    };

    oCustomContextMenu = new CustomContextMenu(Arguments); 

    oCustomContextMenu.AddItem('Images/ei0019-48.gif', 'MyIndex', false, 'MyIndex');


}

var OnClick = function(Sender, EventArgs)
{
    switch(EventArgs.CommandName)
    {
        case 'MyIndex':
            alert('The Index :');
            break;

    }

    oCustomContextMenu.Hide();   
}

window.onunload = function(){ oCustomContextMenu.Dispose(); }
</script>



I need only get the Index value of selected row

What I have tried:

i try :

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {


       if (e.Row.RowType == DataControlRowType.DataRow)
       {
            e.Row.Attributes.Add("onclick", "javascript:rowno(" + e.Row.RowIndex + ")");


       }
   }


with this :
<script type="text/javascript">
       function rowno(rowindex) {
           alert(rowindex);
       }
   </script>


and it work done But I can not merge it with the Right click menu
Posted
Updated 3-Oct-18 21:55pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900