0

Hi guys I am taking values on a page. Clicking on a save button and on the click event want to open up a grid to show values depending on the search made. So i need to transfer these values from search page(on which im taking these values) to the page on which i want the search function to run and display the grid. I did it with the Session state but its not working and giving me this error.

Note that the error looks like this entirely : at line 4
on the DESTINATION FILE CODE

the page on which im taking the values the code behind looks like this---------------

searchFields["PaymentId"] = txtPaymentID.Text;
                searchFields["TOLNumber"] = txtTOLNumber.Text;
                searchFields["ReferenceNumber"] = txtRefNumber.Text;
                searchFields["ContractNumber"] = txtContractNum.Text;
                searchFields["LastName"] = txtCustLName.Text;
                searchFields["FirstName"] = txtCustFName.Text;
                searchFields["CCFirst6"] = txtCCFirst6.Text;
                searchFields["txtCCLast4"] = txtCCLast4.Text;

// HERE I AM TAKING THE VALUES ABOVE IN A SESSION AND PASSING IT ON OTHER PAGE 
                Session["SearchCriteria"] = searchFields;

Destination page looks like this -----------------------

Hashtable searchFields = (Hashtable)Session["SearchCriteria"];

           int paymentID = searchFields["PaymentId"].ToString() == "" ? -1 : Convert.ToInt32(searchFields["PaymentId"].ToString());          
 int tolNumber = searchFields["TOLNumber"].ToString() == "" ? -1 : Convert.ToInt32(searchFields["TOLNumber"].ToString());

            int referenceNumber = searchFields["ReferenceNumber"].ToString() == "" ? -1 : Convert.ToInt32(searchFields["ReferenceNumber"].ToString());

            int contactNumber = searchFields["ContractNumber"].ToString() == "" ? -1 : Convert.ToInt32(searchFields["ContractNumber"].ToString());


            string firstName = searchFields["firstName"].ToString();

            string lastName = searchFields["LastName"].ToString();


            int txtCCFirst6 = searchFields["CCFirst6"].ToString() == "" ? -1 : Convert.ToInt32(searchFields["CCFirst6"].ToString());

            int txtCCLast4 = searchFields["CCLast4"].ToString() == "" ? -1 : Convert.ToInt32(searchFields["CCLast4"].ToString());


THE THE SQL part ----------

SqlParameter[] para = new SqlParameter[]              {  new SqlParameter ("@Payment_ID", paymentID),
                                                                     new SqlParameter ("@TOLNumber", tolNumber),
                                                                     new SqlParameter ("@ContractNumber", contactNumber),
                                                                     new SqlParameter ("@CustFirstName", firstName),
                                                                     new SqlParameter ("@CustLastName", lastName),
                                                                     new SqlParameter ("@CCFirst6",txtCCFirst6),
                                                                     new SqlParameter ("@CCLast4", txtCCLast4),
            ////                                                        //new SqlParameter ("@TransactionID", TransactionID),
                                                                     };

Edited by bhaumik1987: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by guru_sarkar
0

1: so you mean it's erroring out on this line?

int paymentID = searchFields["PaymentId"].ToString() == "" ? -1 : Convert.ToInt32(searchFields["PaymentId"].ToString());

Set breakpoint and see what is null "searchFields" or individual item?

2: Also one other thing I noted is :

searchFields["txtCCLast4"] = txtCCLast4.Text;

searchFields["txtCCLast4"] is not what you are retrieving on destination page.

3: The keys are case-sensitive so: searchFields["FirstName"] and searchFields["firstName"] are different. You are using different cases on both pages.

Edited by guru_sarkar: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.