如何在分页时将所有数据存储在gridview中 [英] how to store all my data in gridview when paging

查看:64
本文介绍了如何在分页时将所有数据存储在gridview中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在分页时将所有数据保留在gridview中,但是当我尝试保存它时,只有当它是活动页面时才显示在我的数据库中..例如:在第一页和第二页中我在gridview中有数据..当我保存时,存储在数据库中的只有第一页或第二页当然..所以我喜欢在分页时将所有数据保存在gridview中



i有尝试使用foreach(GridCustomColumn.Rows中的GridViewRow行),但它不起作用..

  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 = 从report_column中删除 +
,其中report_id =' + report_id + 'and column_name =' + columnname + ';

sql1 = insert into report_column +
values(' + report_id + < span class =code-string>',' + columnname + ',' + columntext + ',' + columnsize + '); +
select * from report_column;
lblmsg.Text + = berhasil untuk tambah报告专栏!!;

mda.execSQL(sql + sql1,connStr);

}
}







your b回答将非常有帮助,谢谢

解决方案

你需要这样做。

 GridCustomColumn.AllowPaging =  false ; 

// 遍历行并保存数据....
// ......
// ......

// 现在,再次将AllowPaging设置为true。
GridCustomColumn.AllowPaging = true ;


只需在从GridView获取数据时将分页设置为false ..再次获取数据后再将其设置为true



例如



 GridName.AllowPaging =  false ; 





在你的情况下,



 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 = 从report_column中删除 +
,其中report_id =' + report_id + 'and column_name =' + columnname + ';

sql1 = insert into report_column +
values(' + report_id + < span class =code-string>',' + columnname + ',' + columntext + ',' + columnsize + '); +
select * from report_column;
lblmsg.Text + = berhasil untuk tambah报告专栏!!;

mda.execSQL(sql + sql1,connStr);

}
}

GridCustomColumn.AllowPaging = true ;


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..

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

解决方案

You need to do like this.

GridCustomColumn.AllowPaging = false;

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

// Now, set AllowPaging to true again.
GridCustomColumn.AllowPaging = true;


Just Set your paging to false while fetching data from GridView.. after fetching data again set it to true

e.g.

GridName.AllowPaging=false;



in your case,

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;


这篇关于如何在分页时将所有数据存储在gridview中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆