Getting this error: Index was out of range. Must be non-negative and less than the size of the collection.

I have an application that gets data returned to it via a stored proc to a gridview. Because there is so much data I am using paging to return the data. I have a image button that is only visible when the when the last page in the paging is returned so that the user can enter in a new row.  The issue that I am having is that the when I start to loop thru the rows to open / insert the new row I get the error message:  Index was out of range. Must be non-negative and less than the size of the collection.
 Which tells me that the data table can not find all of the rows because I am on the last page. In this case the database has over 1200 rows and the last page is only displaying 8 rows. I know what is causing the issue but I don't know how to fix it. My code is listed below.
private void AddNewRowToGrid()
        {  
            Control control = null;

            if (gvCandidateInterviewedTracking.FooterRow != null)
            {
                control = gvCandidateInterviewedTracking.FooterRow;
            }
            else
            {
                control = gvCandidateInterviewedTracking.Controls[0].Controls[0];
            }

            int rowIndex = 0;

            if (ViewState["CurrentTable"] != null)
            {
                DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                DataRow drCurrentRow = null;
                //DataRow drCurrentRow = dtCurrentTable.Rows[dtCurrentTable.Rows.Count - 1];

                if (dtCurrentTable.Rows.Count > 0)
                {
                    for (int i = 0; i <= dtCurrentTable.Rows.Count-1; i++ ) //1 dtCurrentTable.Rows.Count-1; i++) rowIndex; i++
                    {
                        //extract the Textbox values
                        TextBox box1 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[4].FindControl("txtStatus");
                        TextBox box2 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[5].FindControl("txtIdentifiedAgent");
                        TextBox box3 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[6].FindControl("txtResumelastsent");
                        TextBox box4 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[7].FindControl("txtFeedbackreceived");
                        TextBox box5 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[8].FindControl("txtCandidateName");
                        TextBox box6 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[9].FindControl("txtSource");
                        TextBox box7 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[10].FindControl("txtState");
                        TextBox box8 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[11].FindControl("txtCity");
                        TextBox box9 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[12].FindControl("txtPhone");
                        TextBox box10 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[13].FindControl("txtEmail");
                        TextBox box11 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[14].FindControl("txtZipCode");
                        TextBox box12 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[15].FindControl("txtMilesWillingtoTravel");
                        TextBox box13 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[16].FindControl("txtDateEntered");
                        TextBox box14 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[17].FindControl("txtBestwaytocontact");
                        TextBox box15 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[18].FindControl("txtBesttimetocontact");
                        TextBox box16 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[19].FindControl("txtLicenses");
                        TextBox box17 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[20].FindControl("txtSalesExp");
                        TextBox box18 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[21].FindControl("txtInsuranceExp");
                        TextBox box19 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[22].FindControl("txtYrsofInsExp");
                        TextBox box20 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[23].FindControl("txtExpectedSalaryRange");
                        TextBox box21 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[24].FindControl("txtDaysavailable");
                        TextBox box22 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[25].FindControl("txtComfortablcoldcalling");
                        TextBox box23 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[26].FindControl("txtBilingual");
                        TextBox box24 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[27].FindControl("txtMicrosoftOfficeProficiency");
                        TextBox box25 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[28].FindControl("txtInterestSellingInsurance");
                        TextBox box26 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[29].FindControl("txtEmpStatus");
                        TextBox box27 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[30].FindControl("txtNotLicensed");
                        TextBox box28 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[31].FindControl("txtResume");
                        TextBox box29 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[21].FindControl("txtInterview");
                        TextBox box30 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[33].FindControl("txtInterviewTimes");
                        TextBox box31 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[34].FindControl("txtNotes");
                        TextBox box32 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[35].FindControl("txtHireSelect");
                        TextBox box33 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[36].FindControl("txtDateEnteredLSPDB");
                        TextBox box34 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[37].FindControl("txtDateSentToAgent2");
                        TextBox box35 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[38].FindControl("txtAgentSentTo");
                        TextBox box36 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[39].FindControl("txtAgentSalesLeader");
                        TextBox box37 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[40].FindControl("txtOutcome");
                        TextBox box38 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[41].FindControl("txtDateSentToAgent");
                        TextBox box39 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[42].FindControl("txtDateSentToAgent3");
                        TextBox box40 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[43].FindControl("txtAgentSalesLeader2");
                        TextBox box41 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[44].FindControl("txtOutcome2");
                        TextBox box42 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[45].FindControl("txtOtherAgents");
                        TextBox box43 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[46].FindControl("txtHired");
                        TextBox box44 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[47].FindControl("txtHiringAgent");
                        TextBox box45 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[48].FindControl("txtMonthYear");

                        drCurrentRow = dtCurrentTable.NewRow();
                        dtCurrentTable.Rows[i - 0]["Candidate Name"] = box5.Text;

                        string format = "01/01/2000 12:00:00 AM";
                        string[] formats = {"M/d/yyyy h:mm:ss tt", "M/d/yyyy h:mm tt", 
                         "MM/dd/yyyy hh:mm:ss", "M/d/yyyy h:mm:ss", 
                         "M/d/yyyy hh:mm tt", "M/d/yyyy hh tt", 
                         "M/d/yyyy h:mm", "M/d/yyyy h:mm", 
                         "MM/dd/yyyy hh:mm", "M/dd/yyyy hh:mm"};

                        if (box33.Text == "" || box33.Text == null)
                        {
                            box33.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox33 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 0]["Date entered into LSP DB"] = dateBox33;
                        }
                        else if (box33.Text != "" || box33.Text != null)
                        {
                            DateTime dateBox33 = DateTime.ParseExact(box33.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 0]["Date entered into LSP DB"] = dateBox33;
                        }

                        if (box34.Text == "" || box34.Text == null)
                        {
                            box34.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox34 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 0]["Date sent to agent"] = dateBox34;
                        }
                        else if (box34.Text != "" || box34.Text != null)
                        {
                            DateTime dateBox34;
                            dateBox34 = DateTime.ParseExact(box34.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 0]["Date sent to agent"] = dateBox34;
                        }

                        if (box38.Text == "" || box38.Text == null)
                        {
                            box38.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox38 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 0]["Date sent to agent"] = dateBox38;
                        }
                        else if (box38.Text != "" || box38.Text != null)
                        {
                            DateTime dateBox38 = DateTime.ParseExact(box38.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 0]["Date sent to agent"] = dateBox38;
                        }


                        if (box45.Text == "" || box45.Text != null)
                        {
                            box45.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox45 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 0]["Month-Year"] = dateBox45;
                        }
                        else if (box45.Text != "" || box45.Text != null)
                        {
                            DateTime dateBox45 = DateTime.ParseExact(box45.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 0]["Month-Year"] = dateBox45;
                        }

                        dtCurrentTable.Rows[i - 0]["Status"] = box1.Text;
                        dtCurrentTable.Rows[i - 0]["Identified Agent"] = box2.Text;
                        dtCurrentTable.Rows[i - 0]["Resume last sent"] = box3.Text;
                        dtCurrentTable.Rows[i - 0]["Feedback received"] = box4.Text;
                        dtCurrentTable.Rows[i - 0]["Source"] = box6.Text;
                        dtCurrentTable.Rows[i - 0]["State"] = box7.Text;
                        dtCurrentTable.Rows[i - 0]["City"] = box8.Text;
                        dtCurrentTable.Rows[i - 0]["Phone"] = box9.Text;
                        dtCurrentTable.Rows[i - 0]["Email"] = box10.Text;
                        dtCurrentTable.Rows[i - 0]["Zip Code"] = box11.Text;
                        dtCurrentTable.Rows[i - 0]["Miles Willing to Travel"] = box12.Text;
                        dtCurrentTable.Rows[i - 0]["Date Entered"] = box13.Text;
                        dtCurrentTable.Rows[i - 0]["Best way to contact"] = box14.Text;
                        dtCurrentTable.Rows[i - 0]["Best time to contact"] = box15.Text;
                        dtCurrentTable.Rows[i - 0]["Licenses"] = box16.Text;
                        dtCurrentTable.Rows[i - 0]["Sales Exp?"] = box17.Text;
                        dtCurrentTable.Rows[i - 0]["Insurance Exp?"] = box18.Text;
                        dtCurrentTable.Rows[i - 0]["Yrs of Ins Exp"] = box19.Text;
                        dtCurrentTable.Rows[i - 0]["Expected Salary Range All In-BaseCommissions"] = box20.Text;
                        dtCurrentTable.Rows[i - 0]["Days available to work"] = box21.Text;
                        dtCurrentTable.Rows[i - 0]["Comfortable with cold calling?"] = box22.Text;
                        dtCurrentTable.Rows[i - 0]["Bilingual skills?"] = box23.Text;
                        dtCurrentTable.Rows[i - 0]["Microsoft Office proficiency Are you able to Learn new compute"] = box24.Text;
                        dtCurrentTable.Rows[i - 0]["Reason for interest in selling insurance?"] = box25.Text;
                        dtCurrentTable.Rows[i - 0]["Looking for P/T or F/T or will consider both?"] = box26.Text;
                        dtCurrentTable.Rows[i - 0]["Not Licensed--Would study night and weekend?"] = box27.Text;
                        dtCurrentTable.Rows[i - 0]["Resume?"] = box28.Text;
                        dtCurrentTable.Rows[i - 0]["Avail# Interview times Day"] = box29.Text;
                        dtCurrentTable.Rows[i - 0]["Avail# Interview times Hour"] = box30.Text;
                        dtCurrentTable.Rows[i - 0]["Notes"] = box31.Text;
                        dtCurrentTable.Rows[i - 0]["Hire Select?"] = box32.Text;
                        dtCurrentTable.Rows[i - 0]["Agent sent to"] = box35.Text;
                        dtCurrentTable.Rows[i - 0]["Agent Sales Leader"] = box36.Text;
                        dtCurrentTable.Rows[i - 0]["Outcome?"] = box37.Text;
                        dtCurrentTable.Rows[i - 0]["Agent sent to"] = box39.Text;
                        dtCurrentTable.Rows[i - 0]["Agent Sales Leader"] = box40.Text;
                        dtCurrentTable.Rows[i - 0]["Outcome"] = box41.Text;
                        dtCurrentTable.Rows[i - 0]["Other Agents"] = box42.Text;
                        dtCurrentTable.Rows[i - 0]["Hired?"] = box43.Text;
                        dtCurrentTable.Rows[i - 0]["Hiring Agent"] = box44.Text;

                        rowIndex++;
                    }
                    //dtCurrentTable.Rows.Add(drCurrentRow);
                    //ViewState["CurrentTable"] = dtCurrentTable;

                    gvCandidateInterviewedTracking.DataSource = dtCurrentTable;
                    gvCandidateInterviewedTracking.DataBind();
                }
            }
            else
            {

            }
            SetInitialRow();
        }

Open in new window

newjeep19Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WilliamCommented:
Why are you subtracting zero from your count?
      dtCurrentTable.Rows[i - 0]["Candidate Name"] = box5.Text;
This is done in multiple places -
Also - Have you stepped through your loop to see the last line before the exception is thrown?
0
newjeep19Author Commented:
I have also tried setting it to 1 as well. Yes I have stepped thru the code and when the for loop gets to row 8 it throws the error. Because the last page is only displaying 8 rows. I have the page index to display 50 at a time. I know what is causing the error I can't figure out how to fix the error.
0
WilliamCommented:
What is the difference in your code for using your variable rowindex vs i ?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

WilliamCommented:
Can you post the line of code it errors on?
0
newjeep19Author Commented:
The code below is where the error is occurring. What is happening is on the last page there are only 7 rows. When the for loop loops to count 8 it throws the error.  Answerer to this question:
What is the difference in your code for using your variable rowindex vs i ? it was an example that I found trying to google a fix for the error that I am getting.
for (int i = 0; i <= dtCurrentTable.Rows.Count-1; i++ ) //1 dtCurrentTable.Rows.Count-1; i++) rowIndex; i++
                    {
                        //extract the Textbox values
                        TextBox box1 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[4].FindControl("txtStatus");

Open in new window

0
WilliamCommented:
Got it - Thanks for the clarification on the variable.
Did you happen to try :
(int i = 0; i <= dtCurrentTable.Rows.Count; i++ ) //1 dtCurrentTable.Rows.Count-1; i++) rowIndex; i++

Open in new window

?
0
newjeep19Author Commented:
Yes, I also tried your suggestion and I received the same error message.
0
WilliamCommented:
So if you put a break point on the for loop line and hover over dtCurrentTable.Rows.Count it is equal to 8 correct?
0
newjeep19Author Commented:
Correct
0
WilliamCommented:
When it errors - stepping thru - what is i when it bombs?
0
WilliamCommented:
Sorry for ?'s - I am seeing what your seeing - however I can not step thru the code.
0
newjeep19Author Commented:
No worries  I = 7
0
WilliamCommented:
Have you ran this with EVERYTHING inside the loop commented out?
If not - what is result?
Guessing the same - just trying to rule a few things out.
0
WilliamCommented:
How many rows in gvCandidateInterviewedTracking.Rows?
0
WilliamCommented:
One other question - when you step through, are you using F5 or F11?
0
AndyAinscowFreelance programmer / ConsultantCommented:
This probably isn't your problem, just to clarify.
for (int i = 0; i <= dtCurrentTable.Rows.Count-1; i++ )
That will be OK - the collection is zero based so if there are 8 items they are 0 to 7.  The -1 is required or you use
for (int i = 0; i < dtCurrentTable.Rows.Count; i++ ), note just the less than not the <=
0
newjeep19Author Commented:
I tried the suggestion :  (int i = 0; i < dtCurrentTable.Rows.Count; i++ ),
and still getting the same error
0
WilliamCommented:
How many rows in gvCandidateInterviewedTracking.Rows?
When you step through, are you using F5 or F11?
0
käµfm³d 👽Commented:
Are you certain the row has 5 columns? "Cells[4]" means you are indexing into the 5th column.
0
newjeep19Author Commented:
The stored proc pulls in over 1200 rows.  When I debug I am using F10, F11
When I = 8 the error is returned on this list of code:
 TextBox box1 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[4].FindControl("txtStatus");

I comment out that line then this line I still get the error:
TextBox box2 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[5].FindControl("txtIdentifiedAgent");

The error is because the code is expecting over 1200 rows but because of paging the last page only has 7 rows returning on the last page. So when it hits row 8 and there is no data in the row the error is thrown.
My question is how to correct / fix this issue so I can add a new row on the last page.
0
newjeep19Author Commented:
Are you certain the row has 5 columns? "Cells[4]" means you are indexing into the 5th column.

Yes I am because the 1st 4 columns have image buttons in the columns
0
WilliamCommented:
This is the problem
gvCandidateInterviewedTracking.Rows[rowIndex] -
this count is different from your loop count
dtCurrentTable.Rows.
0
newjeep19Author Commented:
So how do I fix this or correct this?
0
WilliamCommented:
You are looping through rows of one data table while updating rows of another -
My first guess would be to use gvCandidateInterviewedTracking.Rows.Count in the loop instead of the other datatable....  I cannot tell you specifically how to fix as I can only see this one method in your code. If you can explain why your iterating one datatable and inside that - updating another - maybe we can solve this error.
0
newjeep19Author Commented:
OK so I linked the data table to that calls the original data table and I still getting the same error see code below:

var _mConn = connectionString;

            //Get data from the refistration table
            DataTable dtCurrentTable = new DataTable();
            var _sqlCom = "sp_Get_ASRDCandidates_Interviewed_Tracking";

            try
            {
                SqlConnection con = new SqlConnection();

                con.ConnectionString = _mConn;

                using (var cmd = new SqlCommand())
                {
                    con.Open();

                    cmd.Connection = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = _sqlCom;

                    using (var sda = new SqlDataAdapter(cmd))
                        sda.Fill(dtCurrentTable);
                }


                int rowIndex = 0;

                if (ViewState["CurrentTable"] != null)
                {
                    //DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                    DataRow drCurrentRow = null;
                    //DataRow drCurrentRow = dtCurrentTable.Rows[dtCurrentTable.Rows.Count - 1];

                    if (dtCurrentTable.Rows.Count > 0)
                    {
                        for (int i = 1; i < dtCurrentTable.Rows.Count; i++) //1 dtCurrentTable.Rows.Count-1; i++) rowIndex; i++
                        {
                            //extract the Textbox values
                            TextBox box1 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[4].FindControl("txtStatus");

Open in new window

0
WilliamCommented:
Your for loop is still a different count of rows than the text box stuff.
Test quickly by commenting out all lines in the loop. If it runs - then uncomment one line at a time until it throws the error.
0
newjeep19Author Commented:
OK I did as you suggested and when I commented out this rowIndex++;
I did not get the error, but it did not create the new row in the gridview. When I un-commented this rowIndex++; It thru the error after looping thru row 7 (I=8)
0
WilliamCommented:
I am still not understanding why The loop is based off of one datatable - and with the iteration count - you are updating a different datatable. Can you explain this? Am I missing something?
0
newjeep19Author Commented:
They are both are the same. How are they different?
0
WilliamCommented:
Dtcurrenttable.Rows !=
dgCanidateInterviewedtracking.Rows

These are 2 different objects
0
newjeep19Author Commented:
Sorry.....I am looking thru the code and I don't see those different objects: Below is my code:
private void AddNewRowToGrid()
        {
            Control control = null;

            if (gvCandidateInterviewedTracking.FooterRow != null)
            {
                control = gvCandidateInterviewedTracking.FooterRow;
            }
            else
            {
                control = gvCandidateInterviewedTracking.Controls[0].Controls[0];
            }

            int rowIndex = 0;

            if (ViewState["CurrentTable"] != null)
            {
                DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                DataRow drCurrentRow = null;

                // if (dtCurrentTable.Rows.Count > 0)
                {
                    for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                    {
                        //   extract the Textbox values
                        TextBox box1 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[4].FindControl("txtStatus");
                        TextBox box2 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[5].FindControl("txtIdentifiedAgent");
                        TextBox box3 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[6].FindControl("txtResumelastsent");
                        TextBox box4 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[7].FindControl("txtFeedbackreceived");
                        TextBox box5 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[8].FindControl("txtCandidateName");
                        TextBox box6 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[9].FindControl("txtSource");
                        TextBox box7 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[10].FindControl("txtState");
                        TextBox box8 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[11].FindControl("txtCity");
                        TextBox box9 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[12].FindControl("txtPhone");
                        TextBox box10 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[13].FindControl("txtEmail");
                        TextBox box11 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[14].FindControl("txtZipCode");
                        TextBox box12 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[15].FindControl("txtMilesWillingtoTravel");
                        TextBox box13 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[16].FindControl("txtDateEntered");
                        TextBox box14 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[17].FindControl("txtBestwaytocontact");
                        TextBox box15 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[18].FindControl("txtBesttimetocontact");
                        TextBox box16 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[19].FindControl("txtLicenses");
                        TextBox box17 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[20].FindControl("txtSalesExp");
                        TextBox box18 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[21].FindControl("txtInsuranceExp");
                        TextBox box19 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[22].FindControl("txtYrsofInsExp");
                        TextBox box20 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[23].FindControl("txtExpectedSalaryRange");
                        TextBox box21 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[24].FindControl("txtDaysavailable");
                        TextBox box22 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[25].FindControl("txtComfortablcoldcalling");
                        TextBox box23 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[26].FindControl("txtBilingual");
                        TextBox box24 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[27].FindControl("txtMicrosoftOfficeProficiency");
                        TextBox box25 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[28].FindControl("txtInterestSellingInsurance");
                        TextBox box26 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[29].FindControl("txtEmpStatus");
                        TextBox box27 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[30].FindControl("txtNotLicensed");
                        TextBox box28 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[31].FindControl("txtResume");
                        TextBox box29 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[21].FindControl("txtInterview");
                        TextBox box30 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[33].FindControl("txtInterviewTimes");
                        TextBox box31 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[34].FindControl("txtNotes");
                        TextBox box32 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[35].FindControl("txtHireSelect");
                        TextBox box33 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[36].FindControl("txtDateEnteredLSPDB");
                        TextBox box34 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[37].FindControl("txtDateSentToAgent2");
                        TextBox box35 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[38].FindControl("txtAgentSentTo");
                        TextBox box36 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[39].FindControl("txtAgentSalesLeader");
                        TextBox box37 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[40].FindControl("txtOutcome");
                        TextBox box38 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[41].FindControl("txtDateSentToAgent");
                        TextBox box39 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[42].FindControl("txtDateSentToAgent3");
                        TextBox box40 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[43].FindControl("txtAgentSalesLeader2");
                        TextBox box41 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[44].FindControl("txtOutcome2");
                        TextBox box42 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[45].FindControl("txtOtherAgents");
                        TextBox box43 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[46].FindControl("txtHired");
                        TextBox box44 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[47].FindControl("txtHiringAgent");
                        TextBox box45 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[48].FindControl("txtMonthYear");

                        drCurrentRow = dtCurrentTable.NewRow();
                        dtCurrentTable.Rows[i - 1]["Candidate Name"] = box5.Text;

                        string format = "01/01/2000 12:00:00 AM";
                        string[] formats = {"M/d/yyyy h:mm:ss tt", "M/d/yyyy h:mm tt", 
                            "MM/dd/yyyy hh:mm:ss", "M/d/yyyy h:mm:ss", 
                            "M/d/yyyy hh:mm tt", "M/d/yyyy hh tt", 
                            "M/d/yyyy h:mm", "M/d/yyyy h:mm", 
                            "MM/dd/yyyy hh:mm", "M/dd/yyyy hh:mm"};

                        if (box33.Text == "" || box33.Text == null)
                        {
                            box33.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox33 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Date entered into LSP DB"] = dateBox33;
                        }
                        else if (box33.Text != "" || box33.Text != null)
                        {
                            DateTime dateBox33 = DateTime.ParseExact(box33.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Date entered into LSP DB"] = dateBox33;
                        }

                        if (box34.Text == "" || box34.Text == null)
                        {
                            box34.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox34 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox34;
                        }
                        else if (box34.Text != "" || box34.Text != null)
                        {
                            DateTime dateBox34;
                            dateBox34 = DateTime.ParseExact(box34.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox34;
                        }

                        if (box38.Text == "" || box38.Text == null)
                        {
                            box38.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox38 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox38;
                        }
                        else if (box38.Text != "" || box38.Text != null)
                        {
                            DateTime dateBox38 = DateTime.ParseExact(box38.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox38;
                        }


                        if (box45.Text == "" || box45.Text != null)
                        {
                            box45.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox45 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Month-Year"] = dateBox45;
                        }
                        else if (box45.Text != "" || box45.Text != null)
                        {
                            DateTime dateBox45 = DateTime.ParseExact(box45.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Month-Year"] = dateBox45;
                        }

                        dtCurrentTable.Rows[i - 1]["Status"] = box1.Text;
                        dtCurrentTable.Rows[i - 1]["Identified Agent"] = box2.Text;
                        dtCurrentTable.Rows[i - 1]["Resume last sent"] = box3.Text;
                        dtCurrentTable.Rows[i - 1]["Feedback received"] = box4.Text;
                        dtCurrentTable.Rows[i - 1]["Source"] = box6.Text;
                        dtCurrentTable.Rows[i - 1]["State"] = box7.Text;
                        dtCurrentTable.Rows[i - 1]["City"] = box8.Text;
                        dtCurrentTable.Rows[i - 1]["Phone"] = box9.Text;
                        dtCurrentTable.Rows[i - 1]["Email"] = box10.Text;
                        dtCurrentTable.Rows[i - 1]["Zip Code"] = box11.Text;
                        dtCurrentTable.Rows[i - 1]["Miles Willing to Travel"] = box12.Text;
                        dtCurrentTable.Rows[i - 1]["Date Entered"] = box13.Text;
                        dtCurrentTable.Rows[i - 1]["Best way to contact"] = box14.Text;
                        dtCurrentTable.Rows[i - 1]["Best time to contact"] = box15.Text;
                        dtCurrentTable.Rows[i - 1]["Licenses"] = box16.Text;
                        dtCurrentTable.Rows[i - 1]["Sales Exp?"] = box17.Text;
                        dtCurrentTable.Rows[i - 1]["Insurance Exp?"] = box18.Text;
                        dtCurrentTable.Rows[i - 1]["Yrs of Ins Exp"] = box19.Text;
                        dtCurrentTable.Rows[i - 1]["Expected Salary Range All In-BaseCommissions"] = box20.Text;
                        dtCurrentTable.Rows[i - 1]["Days available to work"] = box21.Text;
                        dtCurrentTable.Rows[i - 1]["Comfortable with cold calling?"] = box22.Text;
                        dtCurrentTable.Rows[i - 1]["Bilingual skills?"] = box23.Text;
                        dtCurrentTable.Rows[i - 1]["Microsoft Office proficiency Are you able to Learn new compute"] = box24.Text;
                        dtCurrentTable.Rows[i - 1]["Reason for interest in selling insurance?"] = box25.Text;
                        dtCurrentTable.Rows[i - 1]["Looking for P/T or F/T or will consider both?"] = box26.Text;
                        dtCurrentTable.Rows[i - 1]["Not Licensed--Would study night and weekend?"] = box27.Text;
                        dtCurrentTable.Rows[i - 1]["Resume?"] = box28.Text;
                        dtCurrentTable.Rows[i - 1]["Avail# Interview times Day"] = box29.Text;
                        dtCurrentTable.Rows[i - 1]["Avail# Interview times Hour"] = box30.Text;
                        dtCurrentTable.Rows[i - 1]["Notes"] = box31.Text;
                        dtCurrentTable.Rows[i - 1]["Hire Select?"] = box32.Text;
                        dtCurrentTable.Rows[i - 1]["Agent sent to"] = box35.Text;
                        dtCurrentTable.Rows[i - 1]["Agent Sales Leader"] = box36.Text;
                        dtCurrentTable.Rows[i - 1]["Outcome?"] = box37.Text;
                        dtCurrentTable.Rows[i - 1]["Agent sent to"] = box39.Text;
                        dtCurrentTable.Rows[i - 1]["Agent Sales Leader"] = box40.Text;
                        dtCurrentTable.Rows[i - 1]["Outcome"] = box41.Text;
                        dtCurrentTable.Rows[i - 1]["Other Agents"] = box42.Text;
                        dtCurrentTable.Rows[i - 1]["Hired?"] = box43.Text;
                        dtCurrentTable.Rows[i - 1]["Hiring Agent"] = box44.Text;

                        rowIndex++;
                    }
                    dtCurrentTable.Rows.Add(drCurrentRow);
                    //ViewState["CurrentTable"] = dtCurrentTable;

                    gvCandidateInterviewedTracking.DataSource = dtCurrentTable;
                    gvCandidateInterviewedTracking.DataBind();
                }
            }
            else
            {

            }

            SetInitialRow();
        }

Open in new window

Can you point me to the two different objects?
0
WilliamCommented:
I will in a few - sorry i am not on a pc at this time. Give me about 20-30 min i hope
0
WilliamCommented:
You are using the counyt of rows for the loop and using that same count as a row on a different object
private void AddNewRowToGrid()
        {
            Control control = null;

            if (gvCandidateInterviewedTracking.FooterRow != null)
            {
                control = gvCandidateInterviewedTracking.FooterRow;
            }
            else
            {
                control = gvCandidateInterviewedTracking.Controls[0].Controls[0];
            }

            int rowIndex = 0;

            if (ViewState["CurrentTable"] != null)
            {
// HERE YOU SET THE TABLE TO LOOP THRU: dtCurrentTable 
                DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                DataRow drCurrentRow = null;

                // if (dtCurrentTable.Rows.Count > 0)
                {
//HERE YOU START THE LOOP ON dtCurrentTable
                    for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                    {
                        //   extract the Textbox values
//HERE YOU SET ROW VALUES ON A DIFFERENT OBJECT: gvCandidateInterviewedTracking
                        TextBox box1 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[4].FindControl("txtStatus");
                        TextBox box2 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[5].FindControl("txtIdentifiedAgent");
                        TextBox box3 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[6].FindControl("txtResumelastsent");
                        TextBox box4 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[7].FindControl("txtFeedbackreceived");
                        TextBox box5 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[8].FindControl("txtCandidateName");
                        TextBox box6 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[9].FindControl("txtSource");
                        TextBox box7 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[10].FindControl("txtState");
                        TextBox box8 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[11].FindControl("txtCity");
                        TextBox box9 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[12].FindControl("txtPhone");
                        TextBox box10 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[13].FindControl("txtEmail");
                        TextBox box11 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[14].FindControl("txtZipCode");
                        TextBox box12 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[15].FindControl("txtMilesWillingtoTravel");
                        TextBox box13 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[16].FindControl("txtDateEntered");
                        TextBox box14 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[17].FindControl("txtBestwaytocontact");
                        TextBox box15 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[18].FindControl("txtBesttimetocontact");
                        TextBox box16 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[19].FindControl("txtLicenses");
                        TextBox box17 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[20].FindControl("txtSalesExp");
                        TextBox box18 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[21].FindControl("txtInsuranceExp");
                        TextBox box19 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[22].FindControl("txtYrsofInsExp");
                        TextBox box20 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[23].FindControl("txtExpectedSalaryRange");
                        TextBox box21 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[24].FindControl("txtDaysavailable");
                        TextBox box22 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[25].FindControl("txtComfortablcoldcalling");
                        TextBox box23 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[26].FindControl("txtBilingual");
                        TextBox box24 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[27].FindControl("txtMicrosoftOfficeProficiency");
                        TextBox box25 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[28].FindControl("txtInterestSellingInsurance");
                        TextBox box26 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[29].FindControl("txtEmpStatus");
                        TextBox box27 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[30].FindControl("txtNotLicensed");
                        TextBox box28 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[31].FindControl("txtResume");
                        TextBox box29 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[21].FindControl("txtInterview");
                        TextBox box30 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[33].FindControl("txtInterviewTimes");
                        TextBox box31 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[34].FindControl("txtNotes");
                        TextBox box32 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[35].FindControl("txtHireSelect");
                        TextBox box33 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[36].FindControl("txtDateEnteredLSPDB");
                        TextBox box34 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[37].FindControl("txtDateSentToAgent2");
                        TextBox box35 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[38].FindControl("txtAgentSentTo");
                        TextBox box36 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[39].FindControl("txtAgentSalesLeader");
                        TextBox box37 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[40].FindControl("txtOutcome");
                        TextBox box38 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[41].FindControl("txtDateSentToAgent");
                        TextBox box39 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[42].FindControl("txtDateSentToAgent3");
                        TextBox box40 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[43].FindControl("txtAgentSalesLeader2");
                        TextBox box41 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[44].FindControl("txtOutcome2");
                        TextBox box42 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[45].FindControl("txtOtherAgents");
                        TextBox box43 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[46].FindControl("txtHired");
                        TextBox box44 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[47].FindControl("txtHiringAgent");
                        TextBox box45 = (TextBox)gvCandidateInterviewedTracking.Rows[rowIndex].Cells[48].FindControl("txtMonthYear");

                        drCurrentRow = dtCurrentTable.NewRow();
                        dtCurrentTable.Rows[i - 1]["Candidate Name"] = box5.Text;

                        string format = "01/01/2000 12:00:00 AM";
                        string[] formats = {"M/d/yyyy h:mm:ss tt", "M/d/yyyy h:mm tt", 
                            "MM/dd/yyyy hh:mm:ss", "M/d/yyyy h:mm:ss", 
                            "M/d/yyyy hh:mm tt", "M/d/yyyy hh tt", 
                            "M/d/yyyy h:mm", "M/d/yyyy h:mm", 
                            "MM/dd/yyyy hh:mm", "M/dd/yyyy hh:mm"};

                        if (box33.Text == "" || box33.Text == null)
                        {
                            box33.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox33 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Date entered into LSP DB"] = dateBox33;
                        }
                        else if (box33.Text != "" || box33.Text != null)
                        {
                            DateTime dateBox33 = DateTime.ParseExact(box33.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Date entered into LSP DB"] = dateBox33;
                        }

                        if (box34.Text == "" || box34.Text == null)
                        {
                            box34.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox34 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox34;
                        }
                        else if (box34.Text != "" || box34.Text != null)
                        {
                            DateTime dateBox34;
                            dateBox34 = DateTime.ParseExact(box34.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox34;
                        }

                        if (box38.Text == "" || box38.Text == null)
                        {
                            box38.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox38 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox38;
                        }
                        else if (box38.Text != "" || box38.Text != null)
                        {
                            DateTime dateBox38 = DateTime.ParseExact(box38.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Date sent to agent"] = dateBox38;
                        }


                        if (box45.Text == "" || box45.Text != null)
                        {
                            box45.Text = "01/01/2000 12:00:00 AM";
                            DateTime dateBox45 = DateTime.ParseExact(format, "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
                            dtCurrentTable.Rows[i - 1]["Month-Year"] = dateBox45;
                        }
                        else if (box45.Text != "" || box45.Text != null)
                        {
                            DateTime dateBox45 = DateTime.ParseExact(box45.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                            dtCurrentTable.Rows[i - 1]["Month-Year"] = dateBox45;
                        }

                        dtCurrentTable.Rows[i - 1]["Status"] = box1.Text;
                        dtCurrentTable.Rows[i - 1]["Identified Agent"] = box2.Text;
                        dtCurrentTable.Rows[i - 1]["Resume last sent"] = box3.Text;
                        dtCurrentTable.Rows[i - 1]["Feedback received"] = box4.Text;
                        dtCurrentTable.Rows[i - 1]["Source"] = box6.Text;
                        dtCurrentTable.Rows[i - 1]["State"] = box7.Text;
                        dtCurrentTable.Rows[i - 1]["City"] = box8.Text;
                        dtCurrentTable.Rows[i - 1]["Phone"] = box9.Text;
                        dtCurrentTable.Rows[i - 1]["Email"] = box10.Text;
                        dtCurrentTable.Rows[i - 1]["Zip Code"] = box11.Text;
                        dtCurrentTable.Rows[i - 1]["Miles Willing to Travel"] = box12.Text;
                        dtCurrentTable.Rows[i - 1]["Date Entered"] = box13.Text;
                        dtCurrentTable.Rows[i - 1]["Best way to contact"] = box14.Text;
                        dtCurrentTable.Rows[i - 1]["Best time to contact"] = box15.Text;
                        dtCurrentTable.Rows[i - 1]["Licenses"] = box16.Text;
                        dtCurrentTable.Rows[i - 1]["Sales Exp?"] = box17.Text;
                        dtCurrentTable.Rows[i - 1]["Insurance Exp?"] = box18.Text;
                        dtCurrentTable.Rows[i - 1]["Yrs of Ins Exp"] = box19.Text;
                        dtCurrentTable.Rows[i - 1]["Expected Salary Range All In-BaseCommissions"] = box20.Text;
                        dtCurrentTable.Rows[i - 1]["Days available to work"] = box21.Text;
                        dtCurrentTable.Rows[i - 1]["Comfortable with cold calling?"] = box22.Text;
                        dtCurrentTable.Rows[i - 1]["Bilingual skills?"] = box23.Text;
                        dtCurrentTable.Rows[i - 1]["Microsoft Office proficiency Are you able to Learn new compute"] = box24.Text;
                        dtCurrentTable.Rows[i - 1]["Reason for interest in selling insurance?"] = box25.Text;
                        dtCurrentTable.Rows[i - 1]["Looking for P/T or F/T or will consider both?"] = box26.Text;
                        dtCurrentTable.Rows[i - 1]["Not Licensed--Would study night and weekend?"] = box27.Text;
                        dtCurrentTable.Rows[i - 1]["Resume?"] = box28.Text;
                        dtCurrentTable.Rows[i - 1]["Avail# Interview times Day"] = box29.Text;
                        dtCurrentTable.Rows[i - 1]["Avail# Interview times Hour"] = box30.Text;
                        dtCurrentTable.Rows[i - 1]["Notes"] = box31.Text;
                        dtCurrentTable.Rows[i - 1]["Hire Select?"] = box32.Text;
                        dtCurrentTable.Rows[i - 1]["Agent sent to"] = box35.Text;
                        dtCurrentTable.Rows[i - 1]["Agent Sales Leader"] = box36.Text;
                        dtCurrentTable.Rows[i - 1]["Outcome?"] = box37.Text;
                        dtCurrentTable.Rows[i - 1]["Agent sent to"] = box39.Text;
                        dtCurrentTable.Rows[i - 1]["Agent Sales Leader"] = box40.Text;
                        dtCurrentTable.Rows[i - 1]["Outcome"] = box41.Text;
                        dtCurrentTable.Rows[i - 1]["Other Agents"] = box42.Text;
                        dtCurrentTable.Rows[i - 1]["Hired?"] = box43.Text;
                        dtCurrentTable.Rows[i - 1]["Hiring Agent"] = box44.Text;

                        rowIndex++;
                    }
                    dtCurrentTable.Rows.Add(drCurrentRow);
                    //ViewState["CurrentTable"] = dtCurrentTable;

                    gvCandidateInterviewedTracking.DataSource = dtCurrentTable;
                    gvCandidateInterviewedTracking.DataBind();
                }
            }
            else
            {

            }

            SetInitialRow();
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WilliamCommented:
How is it going? Any progress?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.