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

Cut out part of Grid and send it as a table within an email

3 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mSchmidt
Top achievements
Rank 1
mSchmidt asked on 07 Oct 2008, 08:39 AM
Hi

Iam using your grid to display alot of data to my users.

The users have requested a possibility to select some of the rows and the system should then automaticaly create a table (with only some of the values from the original grid).
This table should be added to the top of an email where they could then add additional text.

So far i have added selection to the grid, added a RadEditor to be the email creator.
However what i need is someway to create a table based on the values selected in the RadGrid and then add this table to the RadEditors top.

How can this be accomplished ?

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Oct 2008, 07:02 AM
Hi mSchmidt,

You can dynamically set the content of the editor, as shown in the code snippet below:

.cs
 protected void Button1_Click(object sender, EventArgs e)  
    {  
        StringBuilder values = new StringBuilder();  
        foreach (GridDataItem dataItem in RadGrid1.SelectedItems)  
        {  
            RadEditor1.Content += dataItem["ShipName"].Text + "<br/>";              
        }  
          
    } 

I hope this helps.

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mSchmidt
Top achievements
Rank 1
answered on 10 Oct 2008, 07:28 AM
Hi

Yes this works great for columns that are directly bound, however i have some which use a TemplateColumn, these return an empty string when text is called.

Column parcelUnit
<telerik:GridTemplateColumn   
                        AllowFiltering="false" HeaderText="Mængde colli" UniqueName="parcelUnit"><ItemTemplate><%# string.Format("{0} {1}",DataBinder.Eval(Container.DataItem, "ingredient_parcelquantity") ,DataBinder.Eval(Container.DataItem, "parcel_unit"))%></ItemTemplate></telerik:GridTemplateColumn> 



            HtmlTable mTable = new HtmlTable();  
            System.IO.StringWriter s = new System.IO.StringWriter();  
            HtmlTextWriter htw = new HtmlTextWriter(s);  
            foreach (GridDataItem dataItem in RadGrid_Ingredient.SelectedItems)  
            {  
 
                HtmlTableRow tr = new HtmlTableRow();  
                //for (int i = 0; i < a.Da; i++)  
                //{  
                  
                    HtmlTableCell tc = new HtmlTableCell();  
                    tc.InnerHtml = dataItem["ItemNumber"].Text;  
                    tr.Cells.Add(tc);  
 
                    tc = new HtmlTableCell();  
                    tc.InnerHtml = dataItem["ItemNumber_Creditor"].Text;  
                    tr.Cells.Add(tc);  
 
                    tc = new HtmlTableCell();  
                    tc.InnerHtml = dataItem["parcelUnit"].Text;  
                    tr.Cells.Add(tc);  
                //}  
                mTable.Rows.Add(tr);  
 
            }  
            mTable.RenderControl(htw); 

How do i get the value from these ?
Or should i somehow change from using ItemTemplates ?
0
Accepted
Yavor
Telerik team
answered on 10 Oct 2008, 08:35 AM
Hi mSchmidt,

Once you get a reference to a particular cell, please use the Controls collection, or the FindControl method to get a reference to any control(s) nested in the template column.

Greetings,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
mSchmidt
Top achievements
Rank 1
Answers by
Yavor
Telerik team
mSchmidt
Top achievements
Rank 1
Share this question
or