Click here to Skip to main content
15,125,854 members

Comments by Member 14574143 (Top 13 by date)

Member 14574143 6-Mar-21 5:56am View
   
one more thing please i am now trying to add export button to the table but i failed i tried all the solution on the internet



$(function () {
$.ajax({
type: "POST",
url: "daily.aspx/GetCustomers",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
});
function OnSuccess(response) {
$("[id*=GridView2]").DataTable(
{
"sScrollX": "100%",
"bScrollCollapse": true,
scrollY: "100%",
bLengthChange: true,
lengthMenu: [[5, 10,20, -1], [5, 10,20, "All"]],
bFilter: true,
bSort: true,
bPaginate: true,
data: response.d,
columns: [{ 'data': 'sitecode' },
{ 'data': 'siteid' },
{ 'data': 'region' }]
});
};
Member 14574143 5-Mar-21 10:46am View
   
The problem was caused by the request timeout but not the size of the data. Since I was using ajax updatepanel in aspx project I added AsyncPostBackTimeOut='300000000' to my ToolkitScriptManager tag and added

<system.web.extensions>
<scripting>
<webservices>
<jsonserialization maxjsonlength="300000000">



to my Web.config file as documented here. Now I can load the data without any problem though it's taking some time depending with the number of records returned. Thanks for your help.
Member 14574143 5-Mar-21 10:23am View
   
how could i do that please ?
Member 14574143 5-Mar-21 10:14am View
   
ok could i do that please
Member 14574143 5-Mar-21 10:10am View
   
so no solution ? i am really disappointed.
Member 14574143 5-Mar-21 9:52am View
   
function OnSuccess(response) {
$("[id*=GridView2]").DataTable(
{
bLengthChange: true,
lengthMenu: [[5, 10, -1], [5, 10, "All"]],
bFilter: true,
bSort: true,
bPaginate: true,
data: response.d,
columns: [{ 'data': 'sitecode' },
{ 'data': 'siteid' },
{ 'data': 'region' },
{ 'data': 'bsc' },
{ 'data': 'office' },
{ 'data': 'tier' },
{ 'data': 'category' },
{ 'data': 'subcategory' },
{ 'data': 'owner' }]
});
};


and this is the class icretaed public class Customer
{

public string sitecode { get; set; }
public string siteid { get; set; }
public string region { get; set; }
public string bsc { get; set; }
public string office { get; set; }
public string tier { get; set; }
public string category { get; set; }
public string subcategory { get; set; }
public string owner { get; set; }


}
please support me
Member 14574143 5-Mar-21 9:50am View
   
i dont know if all row loaded in one go or noti folloed the guide oyu sent to me this is my code:
[WebMethod]
public static List<customer> GetCustomers()
{
MySql.Data.MySqlClient.MySqlConnection conn;
MySql.Data.MySqlClient.MySqlCommand cmd;
string queryStr;

List<customer> customers = new List<customer>();

string connstring = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
conn = new MySql.Data.MySqlClient.MySqlConnection(connstring);
conn.Open();
//queryStr = "";
queryStr = "SELECT * FROM webappdemo.dailtest;";
cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

MySql.Data.MySqlClient.MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
customers.Add(new Customer
{
sitecode = dr["sitecode"].ToString(),
siteid = dr["siteid"].ToString(),
region = dr["region"].ToString(),
bsc = dr["bsc"].ToString(),
office = dr["office"].ToString(),
tier = dr["tier"].ToString(),
category = dr["category"].ToString(),
subcategory = dr["subcategory"].ToString(),
owner = dr["owner"].ToString()

});

}

return customers;
}

----------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
//label11.Text = "dd";



if (!this.IsPostBack)
{
// GVbind();
DataTable dummy = new DataTable();
dummy.Columns.Add("sitecode");
dummy.Columns.Add("siteid");
dummy.Columns.Add("region");
dummy.Columns.Add("bsc");
dummy.Columns.Add("office");
dummy.Columns.Add("tier");
dummy.Columns.Add("category");
dummy.Columns.Add("subcategory");
dummy.Columns.Add("owner");
dummy.Rows.Add();
GridView2.DataSource = dummy;
GridView2.DataBind();
GridView2.UseAccessibleHeader = true;
GridView2.HeaderRow.TableSection = TableRowSection.TableHeader;
}

-----------------------
and this is my page


<asp:gridview id="GridView2" runat="server" cssclass="display compact" autogeneratecolumns="false" onselectedindexchanged="GridView1_SelectedIndexChanged">
<columns>
<asp:boundfield datafield="sitecode" headertext="firstname">
<asp:boundfield datafield="siteid" headertext="middlename">
<asp:boundfield datafield="region" headertext="lastname">
<asp:boundfield datafield="bsc" headertext="email">
<asp:boundfield datafield="office" headertext="phonenumber">
<asp:boundfield datafield="tier" headertext="username">
<asp:boundfield datafield="category" headertext="password">
<asp:boundfield datafield="subcategory" headertext="salt">
<asp:boundfield datafield="owner" headertext="saltpassword">

$(function () {
$.ajax({
type: "POST",
url: "daily.aspx/GetCustomers",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
});
function OnSuccess(response) {
$("[id*=GridView2]"
Member 14574143 5-Mar-21 8:30am View
   
it seems it doesn't work with tables have more 10000 row is the database, could you advise please
Member 14574143 5-Mar-21 8:06am View
   
i tried it and it say localhost:44386 says undefined
Member 14574143 5-Mar-21 6:56am View
   
thanks alot for your support i will try and feedback you
Member 14574143 5-Mar-21 6:50am View
   
thanks alot i will try it and feedback you but what about changing the pagination button styles ?
Member 14574143 5-Mar-21 6:44am View
   
how could i make it please also another thing the paging buttons are so classic i want to add button on the page number, thanks alot for your support you are amazing and intelligent!
Member 14574143 5-Mar-21 6:12am View
   
thanks a lot Richard it is working now , but while the page load it takes about 6 sec to apply the jQuery , is there is any solution to make apply the jQuery immediately.