Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
i've two pages "search.aspx" & "View.aspx".


Search.aspx contains one gridview with columns "Name, College","DepartMent"

Select NAME COLLEGE DEPARTMENT

CBox AAAAA BBBBB CCCCC
CBox BBBBB CCCCC DDDDD
CBox CCCCC AAAAA DDDDD

<button text="transfer"></button>

my View.aspx Page Here

Name : lblname
College: lblcollege
Department: lbldepartment


If i've selected all the checkbox in "search.aspx" gridview and clicked the transfer button
then the selected values will move to "View.aspx".

i need a result like
Name : AAAAA , BBBBB , CCCCC
College : BBBBB , CCCCC , AAAAA
Department: CCCCC , AAAAA , DDDDD

is this possible??
please help me..
Posted

Absolutely possible. First you bind your data to gridview on Page_Load Event as follows:

C#
protected void Page_Load(object sender, EventArgs e)
{
      if (!IsPostBack)
            { 
                 //Bind your gridview here.
            }
}


Now you have gridview with four columns NAME,COLLEGE,DEPARTMENT and a checkbox(i assume)

On click event of some button,declare datatable,loop through all the rows and add checked rows to datatable,bind that to gridview.

C#
DataTable dtable = new DataTable();
                dtable.Columns.Add(new DataColumn("NAME", typeof(string)));
                dtable.Columns.Add(new DataColumn("COLLEGE", typeof(string)));
                dtable.Columns.Add(new DataColumn("DEPARTMENT ", typeof(string)));
                Session["dt"] = dtable;
                foreach (GridViewRow gvrow in yourgridview.Rows)
                {
                    dtable = (DataTable)Session["dt"];
                    CheckBox chk = (CheckBox)gvrow.Cells[3].FindControl("CheckBox1");
                    if (chk != null && chk.Checked)
                    {       DataRow dd = dtable.NewRow();
                            dd["NAME"] = (gvrow.Cells[0].Text);
                            dd["COLLEGE"] = (gvrow.Cells[1].Text);
                            dd["DEPARTMENT "] = (gvrow.Cells[2].Text);
                            dtable.Rows.Add(dd);
                            GridView1.DataSource = dtable;
                            GridView1.DataBind();
                     }
                }
                //Here you got the complete list of data(GridView1) which has checkbox checked


Send this gridview to appropriate page.

Happy coding.. :)
 
Share this answer
 
Comments
VIP Venkatesan 7-Jun-13 2:47am    
gvrow.cells[0].text ="" for me..

i wasn't bind the gridview in page load. but i bind it in button click event
Thanks7872 7-Jun-13 2:49am    
I mean to say you see gridview on page with data and checkbox right?that means you binded your grid somewhere....you just check the checkboxes and perform as i suggested so that you will get filtered data in another gridview that is GridView1 in our case.
CSS
You create New Div and Create this 
Name : AAAAA , BBBBB , CCCCC
College : BBBBB , CCCCC , AAAAA
Department: CCCCC , AAAAA , DDDDD


and after click search button this div are visible true and
view page dive are visible false so your problem solve
 
Share this answer
 
I've Tried this one.. but not satisfied.

C#
protected void lbassettransfer_Click(object sender, EventArgs e)
   {
       foreach (GridViewRow gvrow in GridView1.Rows)
       {
           CheckBox chkdelete = (CheckBox)gvrow.FindControl("cbselect");
           if (chkdelete.Checked)
           {
               int ID= Convert.Toint32(GridView1.DataKeys[gvrow.RowIndex].Value);
               ViewState["ID"]=ID;
               ds = objbal.GetSelectedData(ID);
               Session["GETDATASET"] = ds;               
           }
       }
   }
 
Share this answer
 

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