Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
1.62/5 (3 votes)
See more:
I have one repeater which is bind with data sources and it have chechbox also now when we checked some row and click on button then data are show in another repeater
Posted
Updated 16-Jan-15 0:23am
v2
Comments

Let you have two reapeter named rpt1 and rpt2. You want to transfer Item from rpt1to rpt2 on button click which are clicked. I think this is the best solution for you.....check it

C#
protected void btnSend_Click(object sender, EventArgs e)
    {        
        DataTable dt = new DataTable();
        dt.Columns.Add("MenuName");
        dt.Columns.Add("MenuID");

        foreach (RepeaterItem grdRow in rpt1.Items) ////////////// Add new Data from repeater TO Datatable DT
        {
            if (((CheckBox)grdRow.FindControl("chkSelect")).Checked)
            {
                DataRow drow = dt.NewRow();

                Label lblMenuName = (Label)grdRow.FindControl("lblMenuName");

                HiddenField hdnID = (HiddenField)grdRow.FindControl("hdnID");

                drow["MenuName"] = lblMenuName.Text;
                drow["MenuID"] = hdnID.Value;

                dt.Rows.Add(drow);
            }
        }
        if (dt.Rows.Count > 0)
        {
            rpt2.DataSource = dt;
            rpt2.DataBind();
        }
    }

protected void rpt2_RowDataBound(object sender, RepeaterItemEventArgs e)
    {

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView dr = (DataRowView)e.Item.DataItem;

            //e.Row.Cells[0].Text = dr["MenuName"].ToString();
            Label lblMenuName = e.Item.FindControl("lblMenuName") as Label;
            lblMenuName.Text = dr["MenuName"].ToString();

            HiddenField hdnID = e.Item.FindControl("hdnID") as HiddenField;
            hdnID.Value = dr["MenuID"].ToString();
        }
    }
 
Share this answer
 
v3
Dear,
you can easily solve your problem using back-end (Database End ).
 
Share this answer
 
Comments
J{0}Y 16-Jan-15 6:23am    
how ??
you have any example then suggest me please !!

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