hi everbody,
i use contextMenu for right click in griview and display boostrap modal this work ok, but i don't understant how to get id of row to change or delete, here my code
my grid
<asp:GridView ID="GridView1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
DataKeyNames="Id" data-page-size="3" ShowFooter="true" OnRowCreated="GridView1_RowCreated"
OnRowDataBound="GridView1_RowDataBound" OnPageIndexChanging="GridView1_PageIndexChanging"
CssClass="footable" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="CustomerID">
<ItemTemplate>
<asp:Label ID="lbl_CustomerID" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
<asp:HiddenField ID="HiddenField1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CompanyName">
<ItemTemplate>
<asp:Label ID="lbl_CompanyName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ContactName">
<ItemTemplate>
<asp:Label ID="lbl_ContactName" runat="server" Text='<%# Eval("Country") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Salary">
<ItemTemplate>
<asp:Label ID="lbl_Salary" runat="server" Text='<%# Eval("Salary") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
my java call contextmenu and call modal
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.2.4/jquery.contextMenu.css" rel="stylesheet" />
<%-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>--%>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.2.4/jquery.contextMenu.js"></script>
<script type="text/javascript">
$.contextMenu({
selector: '[id*=GridView1]',
className: 'data-title',
callback: function (key, options) {
var m = "clicked: " + key;
if (key == "edit") {
callModal();
GetSelectedRow(this);
} else if (key == "cut") {
window.console && console.log(m) || alert(m + 'cut');
}
else if (key == "cut1") {
callModal2();
GetSelectedRow(this);
}
},
items: {
"edit": { name: "convert 1", icon: "edit" },
"cut": { name: "convert press c key", icon: "cut", accesskey: "c" },
"cut1": { name: "convert 2", icon: "cut" },
"cut2": { name: "convert 2", icon: "cut" },
"cut3": { name: "convert 2", icon: "cut" },
"cut4": { name: "convert 2", icon: "cut" },
"cut5": { name: "convert 2", icon: "cut" },
"copy": { name: "convert 3", icon: "copy" },
"paste": { name: "convert 4", icon: "paste" },
"delete": { name: "convert 5", icon: "delete", disabled: true },
"sep1": "---------",
"quit": { name: "Quit", icon: function ($element, key, item) { return 'context-menu-icon context-menu-icon-quit'; } }
}
});
// set a title
$('.data-title').attr('data-menutitle', "Some JS Title");
</script>
<script type="text/javascript">
function callModal() {
$('#myModal').modal('show');
}
function callModal2() {
$('#myModal2').modal('show');
}
</script>
and modal
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="gridSystemModalLabel">
Test one</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-4">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close</button>
<button type="button" class="btn btn-primary">
Save changes</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
how to get customerId when i right click on gridview row thanks in advance