Reputation: 942
Now this WAS working, I dont know what I've changed but can anyone see why the call is not working im getting getSetContactID is not defined from the browser
Here is the markup from the webform including the script
<asp:TemplateField HeaderText="Quick Donate">
<ItemTemplate>
<asp:Button ID="btnQuickDonate" CssClass="btn-sm btn-primary" runat="server"
CommandName="Insert" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
OnClientClick='<%# "getSetContactID(\"" + Container.DataItemIndex + "\")" %>'
OnClick="btnQuickDonate_Click" Text="Quick 
Donate" />
<script type="text/javascript">
//functions returns the dataitemindex (row Number) from the btnQuickDonate (which is the contactID)
function getSetContactID(rowIndex, obj) {
var CellValue, cell, dataItemIndex;
var table = document.getElementById('<%=GridView1.ClientID %>');
cell = table.rows[parseInt(rowIndex) + 1].cells[1];
//cell = document.getElementById('<%=GridView1.ClientID %>').rows[parseInt(t) + 1].cells[1];
dataItemIndex = cell.innerHTML; //this will get items inside cell (Not needed because the ContactID is hidden so using the row index in row behind with dataitemindex)
//alert(dataItemIndex + "row index" + rowIndex);
$.ajax({
type: "POST",
url: "WebService1.asmx/setContactIDGV1",
data: '{DataItemIndex: "' + rowIndex + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: "done", //after contactID taken click btnQuickDonate to set donation amount
failure: function (response) {
alert(response.d);
}
})
}
</script>
</ItemTemplate>
Upvotes: 0
Views: 410
Reputation: 10275
You are missing second Argument in function calling
OnClientClick='<%# "getSetContactID(\"" + Container.DataItemIndex + "\")" %>'
function getSetContactID(rowIndex, obj) {
Upvotes: 0