Is it possible to load text in a richtextbox from a dataset?

It doesn't sound to complicated but I haven't found any article or such describing how to do it.

Basically I want to select a template name in a combobox, press a button and fetch selected template to the richtextbox with a web service that executes a stored procedure (sql server)

Does anyone of you have any tips about a useful article?

Thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

msglAuthor Commented:
Hi plusone,

That wasn't exactly what I was looking for. The questions is:
If I have a dataset with data such as template id, template name, template description and template data
how do I load the template data into the richtextbox?

The data is stored as binary data in an image field on the server so I have to convert it to a string
but then? Most of the examples I have seen uses a openfiledialog but that isn't what I am looking for.

Thanks in advance.
msglAuthor Commented:
I guess I gave you a bad explanation of what I wanted to do and I will break it down in a few steps.

I have a web service that returns a datatable with selected (from a combobox) template. The datatable has one row with columns id, name, description and data.

I want to assign the data cell to a variable and then convert it from the byte array it is to a string and then load it into the textbox.

My question is how do I get the data cell value  into a variable?
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

msglAuthor Commented:
Ok I got the cell value and convert it to a string with:

        Dim TemplateData As Byte() = TemplateDataTableInstance.Rows(0).Item("TemplateData")
        Dim strTemplateData As String
        Dim enc As New System.Text.UTF8Encoding()
        strTemplateData = enc.GetString(TemplateData)

Now I just need to load the string into the textbox with something like
        Dim strDataFormat As String = DataFormats.Rtf
        Using ms As New MemoryStream(strTemplateData)
            Dim tr As New TextRange(rtbTemplate.Document.ContentStart, rtbTemplate.Document.ContentEnd)
            tr.Load(ms, strDataFormat)
        End Using
it breaks on the dim tr as new textrange line though, is it because  I use a flowdocument in the richtextbox and how do I fix that?

msglAuthor Commented:
I can load the TemplateData as byte() into the richtextbox but not if I convert it to a string,
With byte array I lose the RTF formatting though, any comments?
msglAuthor Commented:
why didn't I try the simplest thing first instead of wasting your time reading this heh

I simply do
        Dim tr As New TextRange(rtbTemplate.Document.ContentStart, rtbTemplate.Document.ContentEnd)
        tr.Text = strTemplateData

I feel so stupid now.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.