This is a migrated thread and some comments may be shown as answers.

[Solved] get selected record from all pages of grid

0 Answers 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Abhi
Top achievements
Rank 1
Abhi asked on 26 Oct 2012, 01:47 PM
hello

i have one rad grid on rad window which has two column one check box column and second is data column 
i am Persist the checked state of checked box upon paging or sorting. 

my problem is on one buttons click i want to get all the selected data which is on another page also i am using the below code for
persisting state
please tell me how can i get all the selected record from other page also



  public string _SelectedID
        {
            set
            {
                ViewState["SelectedID"] = value;
            }
            get
            {
                if (ViewState["SelectedID"] != null)
                {
                    return Convert.ToString(ViewState["SelectedID"]);
                }
                else
                {
                    return ",0,";
                }
            }


        }
        protected void RadGrid1_PreRender(object sender, EventArgs e)
        {


            foreach (GridDataItem item in RadGrid1.Items)
            {
                if (_SelectedID.Contains("," + Convert.ToInt32(item.GetDataKeyValue("OpportunityID")).ToString() + ","))
                {
                    ((CheckBox)item.FindControl("CheckBox1")).Checked = true;
                }
            }


        }




        protected void Button1_Click(object sender, EventArgs e)
        {
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                CheckBox chk = (CheckBox)item.FindControl("CheckBox1");
                if (chk.Checked)
                {
                    string value = item["OpprtunityName"].Text;// access the cell value using ColumnUniqueName
                }
            }
        }
        protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox CheckBox1 = sender as CheckBox;
            GridDataItem item = (GridDataItem)CheckBox1.NamingContainer;
            int ID = Convert.ToInt32(item.GetDataKeyValue("OpportunityID"));
            if (CheckBox1.Checked)
            {
                _SelectedID += ID.ToString() + ",";
            }
            else
            {
                _SelectedID += _SelectedID.Replace(ID.ToString() + ",", "");
            }
        }
Tags
Grid
Asked by
Abhi
Top achievements
Rank 1
Share this question
or