Click here to Skip to main content
14,665,299 members
Rate this:
Please Sign up or sign in to 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

Rate this:
Please Sign up or sign in to vote.

Solution 2

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

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.

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.. :)
   
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.
Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

I've Tried this one.. but not satisfied.

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;               
           }
       }
   }
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100