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 :
<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