Good day,

I am having problem with the saving. all i want is to save multiple records at once. i used user define table in sql server 2008. my stored proc seems be right coz i already tested it..

my problem is that once i selected a record from the first page and move to another page or so.. my selected value seems to be not read in the gridview. all record that they read is the selected record on the active page..

i need some help regarding this..
below is my code for reading the value of selected value..

  gvTaggingAccounts.AllowPaging = false; 

        #region original codes
        DataTable dtTable = new DataTable("AcctTaggingType");
        dtTable.Columns.Add("AccountNum", typeof(Int32));
        dtTable.Columns.Add("AccountName", typeof(string));

        DataRow dtRow;

            foreach (GridViewRow grRow in gvTaggingAccounts.Rows)
            {
                CheckBox chkStatus = (CheckBox)grRow.FindControl("chkTypes");


                if (chkStatus.Checked)
                {
                    //getting the previous record form the gridview

                 dtRow = dtTable.NewRow();

                    //just to return to the first page of the gridview

                 dtTable.Rows.Add(dtRow);

                 dtRow[0] = grRow.Cells[1].Text;
                 dtRow[1] = grRow.Cells[2].Text;




                   // RememberCheckedValues();
                 RepopulateCheckBox();
                    _taggingAccountsManager.InsertAXPerDepartment(dtTable);


                }
            }

The gridview, when paging is being used, does not load all data from the database at once. It only loads what is currently being displayed. So the data you selected on any previous page no longer exists as far as the GridView is concerned. If you want to update data across multiple pages you are going to need to store the data that has been selected in some way, most likely in a session variable. Then when you make the actual update you'll use the data from the Session variable rather than from the GridView.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.