viktors

viktors

  • NA
  • 54
  • 0

Datagrid problem with paging and check boxes...

Sep 8 2004 5:29 PM
hi all, i have a datagrid with a display checkbox column and the datagrid supports paging. paging is working fine but when i change the page the checked items on the previous page are not being retained. only values checked in the last page are being retained..how can i retain all the checked items from all the pages.. thank's my code looks something like this: Select private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { sql = "select * from table1 where type=" + "'"+ mytext +"'" + "order by id"; People.DataSource = CreateDataSource(); People.DataBind(); } } public void Page_Grid(Object sender, DataGridPageChangedEventArgs e) { sql = "select * from table1 where type=" + "'"+ mytext +"'" + "order by id"; // Set CurrentPageIndex to the page the user clicked. People.CurrentPageIndex = e.NewPageIndex; // Rebind the data. People.DataSource = CreateDataSource(); People.DataBind(); } public ICollection CreateDataSource () { //getting the connection from the web.config file. SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["connString"]); SqlDataAdapter db_sqladaptor = new SqlDataAdapter(sql,conn); DataSet ds = new DataSet(); db_sqladaptor.Fill(ds,"MyDataResult"); DataView myView = ds.Tables["MyDataResult"].DefaultView; conn.Close(); return myView; } private void Button1_ServerClick(object sender, System.EventArgs e) { DataGridItemCollection items = People.Items; for (int i=0; i

Answers (6)