Value cannot be null. Parameter name: String Line: int echo = Int32.Parse(Request.Params["sEcho"]

Value cannot be null. Parameter name: String Line: int echo = Int32.Parse(Request.Params["sEcho"]

jaspreetsinghjaspreetsingh Posts: 13Questions: 0Answers: 0
edited June 2012 in General
Hi guys i am trying to implement solution given in below link:

http://datatables.net/forums/discussion/6678/serverside-processing-for-asp.net-c-with-sql-server/p1

When i try to run the code i am getting the error:

on line of code:

Code behind of Default.aspx page:

protected void Page_Load(object sender, EventArgs e)
{

int echo = Int32.Parse(Request.Params["sEcho"]); // here i got error : value can not be null
int displayLength = Int32.Parse(Request.Params["iDisplayLength"]);
int displayStart = Int32.Parse(Request.Params["iDisplayStart"]);

}


You can check the entire code in above link:

aspx is:

$(document).ready(function () {
$('#grid').dataTable({
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "Default.aspx"
});
});


Edit:

I have given values of above three variables Manually :

int echo =1; // here i got error : value can not be null
int displayLength = 10;
int displayStart =0;

Now i am getting the error:

Json data from Server Could not be parsed This is caused by Json formatting error.


Below is my Json:

{"sEcho": 1,"iTotalRecords": 33,"iTotalDisplayRecords": 33,"aaData": [["Gecko","Firefox 1.0","Win 98+ / OSX.2+","1.7","A"],["Gecko","Firefox 1.5","Win 98+ / OSX.2+","1.8","A"],["Gecko","Firefox 2.0","Win 98+ / OSX.2+","1.8","A"],["Gecko","Firefox 3.0","Win 2k+ / OSX.3+","1.9","A"],["Gecko","Camino 1.0","OSX.2+","1.8","A"],["Gecko","Camino 1.5","OSX.3+","1.8","A"],["Gecko","Netscape 7.2","Win 95+ / Mac OS 8.6-9.2","1.7","A"],["Gecko","Netscape Browser 8","Win 98SE+","1.7","A"],["Gecko","Netscape Navigator 9","Win 98+ / OSX.2+","1.8","A"],["Gecko","Mozilla 1.0","Win 95+ / OSX.1+","1","A"]]}





Please help me to resolve the issue.

Thanks

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    If you could run your table through the DataTables debugger, that might give us a clue - however, sEcho is most certainly sent if bServerSide:true is set - so I'd imagine that there is something going wrong int he server-side script somewhere. You might need to ask in a .NET forum for advice about that.

    Allan
  • jaspreetsinghjaspreetsingh Posts: 13Questions: 0Answers: 0
    edited June 2012
    Updates:


    Thanks allan for your reply...

    I am able to use Server Side Processing as described in below link for first time -:) :

    http://datatables.net/forums/discussion/6678/serverside-processing-for-asp.net-c-with-sql-server/p1


    Only issue:

    If while searching , it's not able to find anything then it throws error on line:

    outputJson = outputJson.Remove(outputJson.Length - 1);



    Line 113 of above link as outputJson is coming "" (blank) as no record found.

    I want to display custom message in datatables that "No records found".

    Guys please help i am almost close to closing the deal -:).


    Thanks
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    > Line 113 of above link as outputJson is coming "" (blank) as no record found.

    For "no records found" DataTables requires all of the information as usual (iDisplayRecords etc) with aaData as an empty array.

    Allan
  • jaspreetsinghjaspreetsingh Posts: 13Questions: 0Answers: 0
    Thanks Allan for your reply. Yeah i passed empty array, But default message of No Records Found is not coming.

    Do i need to pass it explicitly?.

    Gud thing is atleast i am able to use Jquery Data Tables now !!!
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    > Do i need to pass it explicitly?.

    I don't understand - you just need to give it an empty array (i.e. [], plus the other parameters required, iDisplayRecords, etc). What does your JSON return for this case look like? It might be worth comparing it to that in my demos.

    Allan
This discussion has been closed.