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

[Solved] Send selected values to other control

2 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 07 Jul 2009, 08:17 PM
I found a great thread here on how to export selected rows to excel/csv/pdf/etc. The code behind used looks like this:
protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
        { 
            dataItemdataItem.Visible = dataItem.Selected;             
        } 
        RadGrid1.MasterTableView.ExportToExcel(); 
    } 
Is there a way to send those selected rows  to a textbox/panel/other control?  Like:

RadGrid1.MasterTableView.FindControl(TextBox1.ClientID);  etc.

Probably a simple solution, but I am not very good at this.  Thanks.

Tom

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Jul 2009, 04:25 AM
Hi Joe,

I am not quite sure about your requirement. I guess you want to show the selected row values in textbox/other controls. If so, get the selected row values and set the text property of control as shown below.

C#:
 
protected void Button3_Click(object sender, EventArgs e) 
    foreach (GridDataItem item in RadGrid1.SelectedItems) 
    { 
        TextBox1.Text = item["ColumnUniqueName1"].Text.ToString(); 
        TextBox2.Text = item["ColumnUniqueName2"].Text.ToString(); 
        TextBox3.Text = item["ColumnUniqueName3"].Text.ToString(); 
        . . .          
    } 

-Shinu.
0
Joe
Top achievements
Rank 1
answered on 08 Jul 2009, 01:00 PM
Shinu,

This is exactly what I was looking for!  Thanks.

One other question, if I may.  For multiple selections is there a 'single' control that would list all selected items from the grid?

Example:  I have a gird where a user selects the row(s) they are interested in.  I want their selections to populate a form that will then be submitted with other information.  Some users may check 1 row, others more.  If possible, it would be easier to have a control that would handle all their selections. From 1 to many.  Listbox, label, and textbox doesn't seem to allow this.

Thanks again Shinu.

joe
Tags
Grid
Asked by
Joe
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Joe
Top achievements
Rank 1
Share this question
or