How can I insert a new row programmatically? Or access the xml schema from c#/InfoPath

G

G. Tarazi

Hi
I have a Microsoft InfoPath 2003 SP1 / VS.NET C# 2003 project.
The schema is created outside the InfoPath form (using VS.NET), and imported later to InfoPath, and it's working correctly.
Now, one of the sections in the schema is repeatable, I would like to use a C# code to insert a new section, similar to the insert link of the section.
To do this, I must write a big amount of code to insert each node manually; I know how to do that.
What I don't know id how to insert a new section with one line, something based on the schema, like what InfoPath does.
Thank you
 
G

G. Tarazi

I don't want to be negative, but thinking back, just imagining the amount of resources that we could have saved if we (the project that I am working on) was designed using Windows Forms instead of InfoPath.



It's the opposite of what we were thinking; now I know that InfoPath is not meant to be used in big applications, just a tool for building forms for none developers, + some developer support.



By now, and after 6 month of daily development, and spending more than 200 dev hours / month in front of that software, I can't see any benefit.



I just can't see anything that this product can do, and windows forms cannot, and that's not all, windows forms are way faster, and way way way more productive, and easier do develop with.



And things like repeating sections, is just having a panel inside another panel inside windows forms, and a small code to make it work.



The form take time to open, it's a large view.

The form is not .net standards; it uses its own version of xml.

And simple things, like adding a new row, cannot be done easily be code, you must call the InfoPath interface and ask him to "execute an action", and I was not able to get that working either.



After this project, I am probably going to windows forms again, and custom controls, but first I am taking therapy, and 2 weeks of vacation :)




I hope Microsoft XAML in Longhorn will solve the xml forms problem.



"G. Tarazi" <Tarazi (at) LiveTechnologies.ca> wrote in message Hi
I have a Microsoft InfoPath 2003 SP1 / VS.NET C# 2003 project.
The schema is created outside the InfoPath form (using VS.NET), and imported later to InfoPath, and it's working correctly.
Now, one of the sections in the schema is repeatable, I would like to use a C# code to insert a new section, similar to the insert link of the section.
To do this, I must write a big amount of code to insert each node manually; I know how to do that.
What I don't know id how to insert a new section with one line, something based on the schema, like what InfoPath does.
Thank you
 
M

Matthew Blain \(Serriform\)

Since you're using C#, you can probably load the InfoPath XML right in to a
dataset or a serialized class. You'll probably have to write it back to the
InfoPath DOM and keep the two in sync if you do that, however.

The issue here is that InfoPath uses the standard DOM methods.
The .NET framework does NOT use the standard DOM methods, but a variant
which is in fact a bit nicer to use. Plus it has a few wrappers (e.g.
datasets, serialized classes) which are even nicer to use.

Using selectSingleNode all the time is a bit of a pain, true.

--Matthew Blain
http://tips.serriform.com/
http://www.microsoft.com/MSPress/books/7128.asp


"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
I don't know much about datasets, but I believe InfoPath SP1 supports them.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com





"G. Tarazi" <Tarazi (at) LiveTechnologies.ca> wrote in message
Thanks for the help

I was trying to say about the .net xml standard is the .net xml classes used
in the, net framework, now we have to learn these classes, the InfoPath xml
classes and the xml standard.

Isn't the idea behind every product update is simplicity, reducing
complexity, and increasing productivity?, you know "do more with less!"

Accessing a field in InfoPath is sending an xpath query to access the field!
And that expression is not captured by the compiler if the schema is
changes, etc. etc. etc.

And about the xml, I know that we can insert an xml string, the problem is
that the repeating section is actually 4 main sections, in one repeating
section, in other words 100+ controls.

And this means, one update on the schema from one of the developers on that
section, and the compiler will not catch the xml string incompatibility with
the schema, and here is a run time error.

When with datasets, you just tell the data set to instance a new node, and
that's it.

And going back I am thinking now, of how much time was lost just to
transform the incoming data to that InfoPath xml, and the tons of errors
that we are having in every stage, like the control is hidden because the
node is not there, etc etc etc





"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
You are correct, InfoPath is not designed to answer every form application
problem and it may be that at some point you will find yourself reverting
back to WinForms for your project.

True, it does not handle large forms in a single view very well.

False, it does not use it's own version of XML. InfoPath does use the XML
standard.

True, WinForms are much faster and can be used in more scenarios.

True, InfoPath would like you to execute actions to perform certain tasks.

But, you will find that InfoPath CAN insert a new row into a table via code
with not much hassle -- its just XML you're dealing with. Its just a matter
of building an XML string representing the table row, and inserting it with
the xml insertBefore() method. You may have to deal with namespace issues
before you can insert it, but that's all standard XML stuff.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com





"G. Tarazi" <Tarazi (at) LiveTechnologies.ca> wrote in message
I don't want to be negative, but thinking back, just imagining the amount of
resources that we could have saved if we (the project that I am working on)
was designed using Windows Forms instead of InfoPath.

It's the opposite of what we were thinking; now I know that InfoPath is not
meant to be used in big applications, just a tool for building forms for
none developers, + some developer support.

By now, and after 6 month of daily development, and spending more than 200
dev hours / month in front of that software, I can't see any benefit.

I just can't see anything that this product can do, and windows forms
cannot, and that's not all, windows forms are way faster, and way way way
more productive, and easier do develop with.

And things like repeating sections, is just having a panel inside another
panel inside windows forms, and a small code to make it work.

The form take time to open, it's a large view.

The form is not .net standards; it uses its own version of xml.

And simple things, like adding a new row, cannot be done easily be code, you
must call the InfoPath interface and ask him to "execute an action", and I
was not able to get that working either.

After this project, I am probably going to windows forms again, and custom
controls, but first I am taking therapy, and 2 weeks of vacation :)

I hope Microsoft XAML in Longhorn will solve the xml forms problem.





"G. Tarazi" <Tarazi (at) LiveTechnologies.ca> wrote in message
Hi
I have a Microsoft InfoPath 2003 SP1 / VS.NET C# 2003 project.
The schema is created outside the InfoPath form (using VS.NET), and
imported later to InfoPath, and it's working correctly.
Now, one of the sections in the schema is repeatable, I would like to use
a C# code to insert a new section, similar to the insert link of the
section.
To do this, I must write a big amount of code to insert each node
manually; I know how to do that.
What I don't know id how to insert a new section with one line, something
based on the schema, like what InfoPath does.
Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top