My first thought when I read your scenario was to create a repeating table in
the Main data source and copy the values over from the secondary data source
to be able to have a rich text field that displays the image. So no, I do not
have any extra ideas and think you are on the right track. And if you need
it, there is an example of populating a repeating table up on my web site
(see
http://enterprise-solutions.swits.n...tically-add-row-repeating-table-xmlwriter.htm).
BTW, since you are creating a shopping cart and retrieving and submitting
data through web services from/to a database, why did you not use a normal
ASP.NET form? Are you storing the XML of the form anywhere? If not, I do not
see the benefit of using an InfoPath form to do this. And as you can see,
because of your image requirement and current limitation of web-based forms,
you lose the benefit of being able to quickly create an InfoPath form without
coding. So why not do everything in ASP.NET? I think you would have more
flexibility that way. Just my 2 cents...
---
S.Y.M. Wong-A-Ton
:
Well, so far I had been populating the repeating control in the following
way. I created the Secondary Data Connection and then I bound the repeating
table up to it. So when I load the form it automatically loads the repeating
table from the SharePoint list without the code.
I followed your suggestion and in one column of repeating table I inserted a
RichText control. I tried to bind it to the same data source, but it was
throwing errors and not letting me do that. So I bound it to a regular
RichText field in the Main Data Source. At this point if I run the form it
displayed all the information and an empty RichText fileld on every row of
data.
So I wrote code that loops through the dataconnection and grabs the url
string from Secondary Data Source
"string url = rows.Current.SelectSingleNode("@thumb_url",
NamespaceManager).Value"
Then I I followed your suggestion and the code from (enterprise-solutions)
to populate txtRichText as image control:
XmlElement elm = doc.CreateElement("img", "
http://www.w3.org/1999/xhtml");
XPathNavigator nav = MainDataSource.CreateNavigator();
XPathNavigator rtfNav = nav.SelectSingleNode("//my:txtRichText",
NamespaceManager);
elm.SetAttribute("src", "C:/bag_briefcase_jpg.jpg");
elm.SetAttribute("width", "75");
doc.AppendChild(elm);
rtfNav.AppendChild(doc.DocumentElement.CreateNavigator());
Unfortunately when I do this, it repeats the same image for every row.
Now, I think that I will probably will have to disconnect the automatic
population of the repeating table, and do it manually through a loop or
something. I was trying to avoid that because one of the cool features of
InfoPath 2007 is to do the connections without the code manipulation. Any
ideas or thoughts would be appreciated.
Dmitriy
:
I would be interested to hear how you got the rich text box in the BOUND
repeating table. Or did you use something else to display images?
I'm assuming that you are looping through a secondary data source to fill a
repeating table with the links to the images. When setting a field in a
repeating group, you need to specify which field you are setting by using a
filter in your XPath expression. For example, if the XPath to the field in
the repeating group is "group2/field1", you must use "group2[3]/field1" to
set the field1 that is in the 3rd row.
---
S.Y.M. Wong-A-Ton
:
I got it to show up an image, but once again I am a little stuck.
I have data pulled from a SharePoint library to a repeating table. One of
the fields is "thumb_url" which I need to use to display images for each row.
However when I add a rich text to the BOUND repeating table, and in the code
I add image reference, what happens is that it loops thru all the "thub_url"
and grabs the last one and therefore for each row I get the same image of the
last item.
Maybe I am missing something... When the rich text control is in the
repeating table, it says that it cannot repeat there... Weird but maybe that
has something to do with it.
I will continue on messing with it, maybe I will figure it out, but will
appreciate any help.
Thank you,
Dmitriy
:
You will have to write code to add the link to an image to the rich text box
control. Just like you can add lines of text to a rich text field (see
http://enterprise-solutions.swits.net/blog/?p=26), you can programmatically
add an <img src="..."/> element, which points to an image, to a rich text
field.
Again, I do not know how you have set up your form template, so am unable to
provide more hints and tips to get your issue fully resolved. I'm currently
short on time, but when I get a free moment, I'll write up an article on how
to do it. The tips I've provided now should get you started. If you get
stuck, let me know.
---
S.Y.M. Wong-A-Ton
:
I am fairly new to infopath 2007 so can you help me out how a form can be set
up for Rich text control to be used as a picture viewer... I would try .asp
way, but truly this is a new combination for me (InfoPath and .net) and I
don't have time to play around with it. So if possible please let me know
more about Rich text control option.
Dmitriy
:
If you are just retrieving images to display items, you don't have to
redesign any of your data connections. If you are submitting images to the
web service, you might have to redesign and things might become a bit more
complex, but it can still be done.
The link I provided actually contains all the code you need. The rest is
just a matter of writing standard ASP.NET code and using ASP.NET controls:
Your form retrieves the list of images through the web service, and passes
this list, which is then just a list of image links to the ASP.NET page for
display. Depending on how your form has been set up, you could even use a
rich text box to display the images. This way you wouldn't have to use a
custom web page, or pass anything between form and page.
---
S.Y.M. Wong-A-Ton
:
I tried looking around for a way to use code to display image, but could not
find anything... ASP.net that might be a solution, but that means I almost
have to redesign all of my data connections. I am using web service to submit
Buyer's Cart data to an Sql database. Then I retrieve it using web service
for review befor submiting to purchasing, which once again uses web service
and send a custom html email.
If any one can give me a start with coding in infopath to put insert images
somehow that would be great. Or anything else that might help...
Dmitriy
:
One possible solution would be to host your form in a custom ASP.NET page
(see
http://msdn2.microsoft.com/en-us/library/aa701078.aspx) and then set up
communication between the form and the ASP.NET page to show the images within
the ASP.NET page.
---
S.Y.M. Wong-A-Ton
:
I have created a form that is web-enabled, but I had to find out the hard way
that image control is not available for web-enabled forms. I am creating a
simple shopping cart type form that gets a list of descriptions and prices
from a sharepoint list. I also have a field that holds the URLs to the images
of each item. I can display the data fine, but the pictures cannot be
displayed since image control is not allowed. Please help me, I have to have
pictures!!!