Loading...

Wednesday, October 15, 2008

Saving the the Repeating table Data with Webservice

Hello All,
Do u want to make the repeating table, to work like gridview ?



Follow these steps

To disable every row of the infopath and enable only after selecting each row
a)Set any textbox value as hidden control and set its default value to 0(Textbox should be inside repeating table and binding field representable for textbox should be repeating)
b)To make every control disabled inside repeating table ,you need to use the conditional formatting for every control ,selecting field of the table



now on click of the select button u neeed to change the value of hidden textbox
as follows
public void btnSelect_Clicked(object sender, ClickedEventArgs e)
{

//code to enable the disabled row of repeating table
XPathNavigator MainDs = MainDataSource.CreateNavigator();

XPathNavigator x1 = e.Source.SelectSingleNode("CompanyID", NamespaceManager);

MainDs.SelectSingleNode("/my:myFields/my:hidden", NamespaceManager).SetValue(x1.InnerXml.ToString());//Set the hidden field value



}

After updating values of selected row, saving the value to database

//Executing the webservice programaticaly
public void btnSave_Clicked(object sender, ClickedEventArgs e)
{


// DataConnection dn = new DataConnection();
// WebServiceConnection wb = new WebServiceConnection();
//// wb.
XPathNavigator MainDs = MainDataSource.CreateNavigator();

MainDs.SelectSingleNode("/my:myFields/my:hidden", NamespaceManager).SetValue("0");//Set the hidden field value

// Open connection.
WebServiceConnection wsc = (WebServiceConnection)this.DataConnections["SaveComp"];//Name of the webservice as dataconnection

// Create XmlDocuments.
XmlDocument inputDocument = new XmlDocument();
XmlDocument outputDocument = new XmlDocument();
XmlDocument errorsDocument = new XmlDocument();

// Load input document.
XPathNavigator x1 = e.Source.CreateNavigator();
// inputDocument.LoadXml(x1.OuterXml.ToString());
//SaveDepartmentsWithID
inputDocument.LoadXml(@"<SaveDepartmentsWithID xmlns='http://tempuri.org/'>" + x1.InnerXml.ToString() + "");//Name of the webmethod SaveDepartmentsWithID

// Create XPathNavigator objects for documents.
XPathNavigator inputNav = inputDocument.CreateNavigator();
XPathNavigator outputNav = outputDocument.CreateNavigator();
XPathNavigator errorsNav = errorsDocument.CreateNavigator();

// Call Execute method.
wsc.Execute(inputNav, outputNav, errorsNav);






// Write your code here.
}