Hello, I can see the DataTables Rows on Alert with Your Support
Now I need to transfer the information in this row to List Class instead of warning If I Transfer to List Class I Will Use Where Required
How do I do this?
My codes are as follows
TemsilciSiparisIslemleri.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/TemsilciIslemleri.Master" AutoEventWireup="true" CodeBehind="TemsilciSiparisIslemleri.aspx.cs" Inherits="BilgiYonetimSistemi.TemsilciSiparisIslemleri" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="container-fluid px-xl-5">
<section class="py-5">
<div class="row">
<div class="col-lg-12 mb-4">
<div class="card">
<div class="card-header">
<h6 class="text-uppercase mb-0">Satış Temsilci Sipariş İşlemleri</h6>
</div>
<div class="card-body">
<div style="overflow-x: auto;">
<div>
<asp:TextBox ID="TextBox1" runat="server" CssClass="form-control"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox2" runat="server" CssClass="form-control"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox3" runat="server" CssClass="form-control"></asp:TextBox>
<br />
<asp:Button ID="BTNSatisIslemleri" runat="server" CssClass="btn btn-primary shadow px-5 shadow form-control-range" Text="Ekle" OnClientClick="return false" />
<br />
<asp:TextBox ID="TextBox4" runat="server" CssClass="form-control"></asp:TextBox>
<br />
</div>
<table id="SatisTemsilcisiSiparisListesi" class="table table-striped card-text">
<thead>
<tr>
<th scope="col">Name and Surname</th>
<th scope="col">Age</th>
<th scope="col">Country</th>
</tr>
</thead>
</table>
<br />
<asp:Button ID="BTNIslemTamamla" runat="server" CssClass="btn btn-primary shadow px-5 shadow form-control-range" Text="Tamamla" OnClick="BTNIslemTamamla_Click" OnClientClick="return false" />
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<script type="text/javascript">
$(document).ready(function () {
var table = $('[id*=SatisTemsilcisiSiparisListesi]').DataTable({
"order": [[2, "asc"]],
dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
});
$('[id*=BTNSatisIslemleri]').click(function () {
var rowNode = table
.row.add([$('[id*=TextBox1]').val(), $('[id*=TextBox2]').val(), $('[id*=TextBox3]').val()])
.draw()
.node();
$(rowNode).css('color', 'black').animate({ color: 'black' });
});
$('[id*=BTNIslemTamamla]').click(function () {
var customers = [];
table.rows().data().each(function (value, index) {
var obj = {};
obj.Name = value[0];
obj.Age = value[1];
obj.Country = value[2];
customers.push(obj);
});
//Send the JSON array to WebMethod using AJAX.
$.ajax({
type: "POST",
url: "TemsilciSiparisIslemleri.aspx/InsertCustomers",
data: '{ customers :' + JSON.stringify(customers) + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
alert(r.d + " record(s) inserted.");
}, error: function (r) {
}
});
});
});
</script>
</asp:Content>
TemsilciSiparisIslemleri.aspx.cs
using System;
using System.Collections.Generic;
namespace BilgiYonetimSistemi
{
public partial class TemsilciSiparisIslemleri : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
public static int InsertCustomers(List<SiparisListesi> customers)
{
// Rest of your code.
return customers.Count;
}
protected void BTNIslemTamamla_Click(object sender, EventArgs e)
{
}
}
}
SiparisListesi.cs
using System.Collections.Generic;
namespace BilgiYonetimSistemi
{
public class SiparisListesi
{
public string Name { get; set; }
public int Age { get; set; }
public string Country { get; set; }
}
}