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

[Solved] Selecting some items and on click of button appear checked to other side:

1 Answer 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 11 May 2009, 04:45 AM
Hi,

   I need to select some items which are displayed on left end and press of button which is at center, appear selected items to right end. Is there this implemented in Telerik. If so, please let me know Url of it.



Thanks,
Josh.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 May 2009, 06:56 AM

Hi Josh,

One suggestion is, using two grids to achieve this. In the example below I stored the selected rows of the first grid in a DataTable and set that DataTable as the DataSource for the second grid inside the buttonClick event. Here is the code which I tried.

ASPX:

 
<telerik:radgrid id="RadGrid1" runat="server" datasourceid="SqlDataSource1" AllowMultiRowSelection="true">  
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False">  
<Columns> 
    <telerik:GridBoundColumn DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" UniqueName="CategoryID" DataType="System.Int32"></telerik:GridBoundColumn> 
</Columns> 
</MasterTableView> 
<ClientSettings> 
    <Selecting AllowRowSelect="True"></Selecting>     
</ClientSettings> 
</telerik:radgrid> 
 
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Export to New Grid" /> 
          
<telerik:radgrid id="Radgrid2" runat="server">  
   <MasterTableView AutoGenerateColumns="False">  
        <Columns>                      
            <telerik:GridBoundColumn DataField="CategoryID" HeaderText="CategoryID" UniqueName="CategoryID" DataType="System.Int32">  
            </telerik:GridBoundColumn> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 

CS:

 
protected void Button1_Click(object sender, EventArgs e)  
{  
    DataTable dt = new DataTable();  
    dt.Columns.Add("CategoryID");  
    foreach (GridDataItem item in RadGrid1.SelectedItems)  
    {  
        DataRow newRow = dt.NewRow();  
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)  
        {  
            if (col.UniqueName == "CategoryID")  
            {  
                newRow["CategoryID"] = item["CategoryID"].Text;  
            }  
        }  
        dt.Rows.Add(newRow);  
    }  
    Radgrid2.DataSource = dt;  
    Radgrid2.DataBind();  

Thanks,
Princy.

Tags
General Discussions
Asked by
Josh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or