Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried to keep all the data in the gridview when paging, but when I try to save it, which appears in my database only when it is active pages .. ex: in the first and second page I have data in gridview .. when I save, the stored in the database only the first or second page of course .. so I like to keep all my data in gridview when paging

i have tried using foreach (GridViewRow row in GridCustomColumn.Rows), but it's not working..
C#
string sql1;
          foreach (GridViewRow row in GridCustomColumn.Rows)
          {
                  string report_id = lblreportid.Text;
                  string columnname = (row.FindControl("lblcolumn") as Label).Text;
                  string columntext = (row.FindControl("txttextcol") as TextBox).Text;
                  string columnsize = (row.FindControl("txtsize") as TextBox).Text;

                  string sql = "delete " +
                         " from report_column where report_id='" + report_id + "' and column_name='" + columnname + "'";

                  sql1 = "insert into report_column " +
                  "values('" + report_id + "', '" + columnname + "', '" + columntext + "','" + columnsize + "');"+
                  "select * from report_column";
                  lblmsg.Text += "berhasil untuk tambah report column !!";

                  mda.execSQL(sql + sql1, connStr);

              }
          }



your answer will be very helpfull, thanks
Posted
Comments
ZurdoDev 7-Dec-14 22:14pm    
This does not make any sense. Please explain more clearly.
Member 11165607 7-Dec-14 22:55pm    
well me explain:
I have a gridview and I have made a page in gridview,
when I save in the database only the data in the gridview on the first page are stored, but the data in the gridview on the second page does not participate stored .. understandable?

You need to do like this.
C#
GridCustomColumn.AllowPaging = false;

// Loop throught the rows and save data....
// ......
// ......

// Now, set AllowPaging to true again.
GridCustomColumn.AllowPaging = true;
 
Share this answer
 
Just Set your paging to false while fetching data from GridView.. after fetching data again set it to true

e.g.

C#
GridName.AllowPaging=false;


in your case,

C#
GridCustomColumn.AllowPaging = false;

foreach (GridViewRow row in GridCustomColumn.Rows)
           {
                   string report_id = lblreportid.Text;
                   string columnname = (row.FindControl("lblcolumn") as Label).Text;
                   string columntext = (row.FindControl("txttextcol") as TextBox).Text;
                   string columnsize = (row.FindControl("txtsize") as TextBox).Text;

                   string sql = "delete " +
                          " from report_column where report_id='" + report_id + "' and column_name='" + columnname + "'";

                   sql1 = "insert into report_column " +
                   "values('" + report_id + "', '" + columnname + "', '" + columntext + "','" + columnsize + "');"+
                   "select * from report_column";
                   lblmsg.Text += "berhasil untuk tambah report column !!";

                   mda.execSQL(sql + sql1, connStr);

               }
           }
  
GridCustomColumn.AllowPaging = true;
 
Share this answer
 
Comments
Member 11165607 8-Dec-14 5:17am    
ok thanks, it's worked !!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900