I've found bits and pieces of this all over the internet without the final piece of the puzzle. I have two Lists from SharePoint: Vendor & Vendor Equipment. I want to create a cascading dropdown using the value selected from vendor to create the secondary data source from Vendor Equipment. I found how to retrieve the data as if it were XML (http://server/site/subsite/_vti_bin/owssvr.dll?Cmd=Display&List={listnumber}&XMLDATA=TRUE) and created a changed event to re-query using the filter value (code follows).
The last piece of the puzzle is the filter of my dropdown doesn't work because the value I'm filtering on is a lookup field from SharePoint. So while the vendor I've picked is "Company ABC" the value in my secondary datasource is "1;#Company ABC". I'm thinking after doing the q.Execute(); I need to somehow update the attributes of the xml to equal the vendor name, but I can't find how to do this.
Does anyone have the solution for this, or can point me to the right article?
public void vendor_Changed(object sender, XmlEventArgs e)
{
SetVendorDetails();
}
private void SetVendorDetails()
{
FileQueryConnection q = (FileQueryConnection)this.DataConnections["VendorEquipmentListXML"];
string OriginalFileLocation = string.Copy(q.FileLocation);
q.FileLocation = q.FileLocation + "&FilterField1=Vendor&FilterValue1=" + GetVendorValue();
q.Execute();
q.FileLocation = OriginalFileLocation;
}
private string GetVendorValue()
{
XPathNavigator nav = this.CreateNavigator();
string filterValue = (string)nav.SelectSingleNode("/my:requisitionPriceQuote/my:vendor", this.NamespaceManager).ValueAs(typeof(string));
return filterValue;
}