內工作現在,這是工作,我不知道什麼 我已經改變了,但不是從瀏覽器JavaScript函數調用不gridview的
這裏定義的任何人都可以看到爲什麼呼叫沒有工作 即時得到getSetContactID從網絡表單的標記包括腳本
<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>
貌似工作 - 雖然它已經與腳本工作中=謝謝 – AShah