Input string was not in a correct format (Paging)

From: RelaxoRy (relaxory_at_postmaster.co.uk)
Date: 04/21/04


Date: 20 Apr 2004 23:30:35 -0700


{
Line 47: sqlConnection1.Open();
Line 48: myReader = currentSqlCommand.ExecuteReader();
Line 49:
Line 50: DataGrid1.AllowCustomPaging=true;

It hangs on line 48 with the subject error. I have a feeling it's
because of the line below :

cmdNext.Parameters["@productid"].Value = "";
Like do i have to somehow convert it to an int somewhere?

-- Code extract

private void Page_Load(object sender, System.EventArgs e)
        
{
        if (!IsPostBack)
        {
        cmdNext.Parameters["@productid"].Value = "";
        CurrentPage = 0;
        FillGrid(cmdNext);
        }
}
private void FillGrid(SqlCommand currentSqlCommand)
{
        sqlConnection1.Open();
        myReader = currentSqlCommand.ExecuteReader();
        DataGrid1.AllowCustomPaging=true;
        DataGrid1.VirtualItemCount=100;
        DataGrid1.CurrentPageIndex=0;
        DataGrid1.PageSize=10;

        DataGrid1.DataSource = myReader;
        DataGrid1.DataBind();
        myReader.Close();
        sqlConnection1.Close();

        ViewState["CurrentPage"] = CurrentPage;
        ViewState[CurrentPage.ToString()] = DataGrid1.Items[0].Cells[0].Text;

        if (DataGrid1.Items.Count < DataGrid1.PageSize)
        {
                btnNext.Enabled = false;
        }
}