problem in custom paging..
-
Hi all, i'm having problem in custom paging using web application..there is an error saying "Input string was not in a correct format." Here is my coding.. protected void NavigationLink_Click ( Object sender, CommandEventArgs e ) { switch ( e.CommandName ) { case "First": _currentPageNumber = 1; break; case "Last": _currentPageNumber = Int32.Parse(TotalPages.Text); break; case "Next": _currentPageNumber = Int32.Parse(CurrentPage.Text) + 1; break; case "Prev": _currentPageNumber = Int32.Parse(CurrentPage.Text) - 1; break; } BindData(); } public void BindData() { OdbcConnection myconn; myconn= new OdbcConnection ("DSN=myodbc2;SERVER=localhost;DATABASE=misdb;UID=root;PORT=3306"); OdbcCommand cmd2 = new OdbcCommand("Select * from registration", myconn); cmd2.CommandType=CommandType.StoredProcedure; cmd2.Parameters.Add(new OdbcParameter ("@CurrentPage",OdbcType.Numeric,10)).Value=_currentPageNumber; cmd2.Parameters.Add(new OdbcParameter("@PageSize",OdbcType.Numeric,10)).Value=DataGrid.PageSize; cmd2.Parameters.Add(new OdbcParameter("@TotalRecords",OdbcType.Numeric,10)).Direction =ParameterDirection.Output; try { myconn.Open(); DataGrid.DataSource=cmd2.ExecuteReader(); DataGrid.DataBind(); } finally { myconn.Close(); } CurrentPage.Text=_currentPageNumber.ToString(); Double _totalPages = 1; if ( !Page.IsPostBack ) { Int32 _totalRecords = (Int32) cmd2.Parameters["@TotalRecords"].Value; totalPages = _totalRecords / DataGrid.PageSize; TotalPages.Text =(System.Math.Ceiling(_totalPages)).ToString(); } else { _totalPages = Double.Parse(TotalPages.Text); } if ( _currentPageNumber == 1 ) { PreviousPage.Enabled = false; if ( _totalPages > 1 ) { NextPage.Enabled = true; } else { NextPage.Enabled = false; } } else { PreviousPage.Enabled = true; if ( _currentPageNumber == _totalPages ) { NextPage.Enabled = false; } else { NextPage.Enabled = true; } } }
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG
-
Hi all, i'm having problem in custom paging using web application..there is an error saying "Input string was not in a correct format." Here is my coding.. protected void NavigationLink_Click ( Object sender, CommandEventArgs e ) { switch ( e.CommandName ) { case "First": _currentPageNumber = 1; break; case "Last": _currentPageNumber = Int32.Parse(TotalPages.Text); break; case "Next": _currentPageNumber = Int32.Parse(CurrentPage.Text) + 1; break; case "Prev": _currentPageNumber = Int32.Parse(CurrentPage.Text) - 1; break; } BindData(); } public void BindData() { OdbcConnection myconn; myconn= new OdbcConnection ("DSN=myodbc2;SERVER=localhost;DATABASE=misdb;UID=root;PORT=3306"); OdbcCommand cmd2 = new OdbcCommand("Select * from registration", myconn); cmd2.CommandType=CommandType.StoredProcedure; cmd2.Parameters.Add(new OdbcParameter ("@CurrentPage",OdbcType.Numeric,10)).Value=_currentPageNumber; cmd2.Parameters.Add(new OdbcParameter("@PageSize",OdbcType.Numeric,10)).Value=DataGrid.PageSize; cmd2.Parameters.Add(new OdbcParameter("@TotalRecords",OdbcType.Numeric,10)).Direction =ParameterDirection.Output; try { myconn.Open(); DataGrid.DataSource=cmd2.ExecuteReader(); DataGrid.DataBind(); } finally { myconn.Close(); } CurrentPage.Text=_currentPageNumber.ToString(); Double _totalPages = 1; if ( !Page.IsPostBack ) { Int32 _totalRecords = (Int32) cmd2.Parameters["@TotalRecords"].Value; totalPages = _totalRecords / DataGrid.PageSize; TotalPages.Text =(System.Math.Ceiling(_totalPages)).ToString(); } else { _totalPages = Double.Parse(TotalPages.Text); } if ( _currentPageNumber == 1 ) { PreviousPage.Enabled = false; if ( _totalPages > 1 ) { NextPage.Enabled = true; } else { NextPage.Enabled = false; } } else { PreviousPage.Enabled = true; if ( _currentPageNumber == _totalPages ) { NextPage.Enabled = false; } else { NextPage.Enabled = true; } } }
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG
Entering something in the CurrentPage field would cause that to happen. To avoid that, use the int.TryParse method to parse the value so that you can easily detect any illegal input.
Despite everything, the person most likely to be fooling you next is yourself.
-
Entering something in the CurrentPage field would cause that to happen. To avoid that, use the int.TryParse method to parse the value so that you can easily detect any illegal input.
Despite everything, the person most likely to be fooling you next is yourself.
hI, I cant c TryParse method in program.Got any other solution for this problem..?
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG
-
hI, I cant c TryParse method in program.Got any other solution for this problem..?
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG
-
Of course you can't see any TryParse in the program. I said that you should use TryParse in the program.
Despite everything, the person most likely to be fooling you next is yourself.
ok thank you.
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG