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

Mail merge using datatable

3 Answers 223 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 03 Mar 2016, 08:47 AM

Hi

Is it possible to use the data within a datatable as the mail merge fields within a richtecteditor? So the column headings within the datatable will show in the 'Insert merge field' drop down and the rows will be the results. 

I have tried (which was a long shot):

Form.RadRichTextEditor.Document.MailMergeDataSource.ItemsSource = DataSet1.Tables("table").AsEnumerable.ToList   (doesn't work)

If its not possible could someone please suggest a best method? The data comes from a SQL view, which fills a datatable which then displays in the radgridview (which is awesome). Preferably in VB.net please.

 

Many thanks

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 04 Mar 2016, 09:41 AM
Hello Daniel,

Thank you for writing.

This will give you a list of rows only. To properly convert the data table you should create a business object class where you should add a property for each column. Then you can iterate the rows and create a proper data source. An example for this is available in the following discussion: c# - Convert DataTable to IEnumerable<T> - Stack Overflow

Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Daniel
Top achievements
Rank 1
answered on 07 Mar 2016, 01:27 PM

Thank you for your reply. This got me on to the right track. 

I actually did it a slightly different way with the following: 

    Public Function mailmergeitems(ByRef datatable_var As DataTable)
        Dim data = datatable_var.AsEnumerable().[Select](Function(row) New With { _
         Key .Student_Family_Name = row("Student_Family_Name").ToString(), _
         Key .Student_First_Name = row("Student_First_Name").ToString() _

})
        Shared_document_creator.RadRichTextEditor1.Document.MailMergeDataSource.ItemsSource = data

0
Dimitar
Telerik team
answered on 07 Mar 2016, 01:39 PM
Hi Daniel,

I am glad I could be of help. Let us know if you have any other questions.

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
RichTextEditor
Asked by
Daniel
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or