Skip to main content
I have an interesting situation with the K2Listbox control I have designed a web page that has a regualar asp textbox and button on it as well as a k2listbox. The button will simple add whatever is in the textbox to the k2Listbox. However, when I click on submit nothing is stored in the XMLfield.

I've spent hours both trying to debug it myself and on the phone with support so I fully expect this to be a probelm so simple that my 9 year old could see it and I will be smacking myself in the head for missing something so simple. Can someone see where I have gone astray?

The K2ListBox is defined as:

<K2:K2LISTBOX id="K2SkuList" runat="server" Width="336px" Height="120px" DataField="ProcXML: EOL_DOCUMENT" DataXPath="/EOLDocument/AffectedSKUs/AffectedSKU"></K2:K2LISTBOX>

Based on conversations with support i have tried both
DataXPath="/EOLDocument/AffectedSKUs/AffectedSKU"
and
DataXPath="/EOLDocument/AffectedSKUs"

The schema for the document is below.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" elementFormDefault="qualified" attributeFormDefault="qualified" id="XMLField">
<xs:element name="EOLDocument">
<xs:complexType>
<xs:sequence>
<xs:element name="Originator" type="xs:string">
<xs:annotation>
<xs:documentation>The Originator (PM) of the EOL Document. </xs:documentation>
</xs:annotation>
</xs:element>
...
<xs:element name="AffectedSKUs" minOccurs="0">
<xs:annotation>
<xs:documentation>List of SKUs efected by EOL </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="AffectedSKU" type="xs:stirng" />
</xs:choice>
</xs:complexType>
</xs:element>
...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Any help would be be appreciated. Really hoping that one of the guys back in South Africa get a load of this!

Thank you,

Michael Fischer
This is an interesting one Michael, I kinda tried to do what you are trying to do but were also unable to bind the ListBox to the XML field, I am not sure about the reason.

If I bind the XML field to a K2.net DataGrid it works, so maybe you can use a DataGrid, and with the right formatting it will look exactly like a ListBox.

I Agree, if anybody from labs can shed some light on this it will be great.
PS: you have a typo in:

<xs:element name="AffectedSKU" type="xs:stirng" />

should be ...string 😉
Thanks for catching the typo. One would hope that the IDE would have caught that. :)

Eric from support gave me some feedback today that allowed me to come up with a way to do it. Doesn't perform very well but I don't expect my listboxes to grow to large. What I have to do is...

1) Create a invisible textbox to hold the same xml that gets bound to the listbox
2) In on_load I populate the list box by parsing this xml and set the DataField and DataXPath to "" so that nothing happens on submit
3) On submit, I loop through the list box and mark everything as selected, which allows it to get saved into the process data.

Now I have another situation where one of my Process XML is getting corrupted. I have Helper and EOL_Document. The EOL_DOCUMENT is getting copied tothe helper node. I'm too tired to figure it out right now but it is a strange one. It has to be something in the client activity but I am missing it. :)

Michael
Yes, I also saw that binding to the ListBox 'corrupts' the XML data some how.

personally I would not go thru the hidden text box route, just bind it to a K2.net DataGrid.

Cheers
Yeah, I thought about that but opted against the datagrid because the interface is too clunky. If I could figure out a way to add a textbox and "add" button to the footer I would would do that in an instance. However, I've haven't been able to figure out that trick with the K2datagrid, it is easy enough with a normal datagrid but with the K2 one I ran into trouble.

I just don't like that peksy add button on every line. Nor do I like the fact that you can't differentiate between when the add button is clicked and when the edit button is clicked in the datagrid ItemCommand method. Well, maybe you can, but then you would be a wiser man than I becuase I couldn't! :)

Michael
Yip, I agree,
it is better to go with Eric's solution if you don't want the add/edit button stuff on each row.

Reply