Need help with XSLT & CSharp to get key of child record

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<pre>I am trying to update a nested record using csharp and xslt. I want to be able to get at the TopicAnswerID for each TopicAnalysisbyTopicAnalysisID Here is my xslt code:

<xsl:when test="/root/BaseInfo/QueryData/m = EditAnalysis
<form action="topics.aspx?m=SaveExistingAnalysis" name="UpdateAnalysis"
enctype="multipart/form-data" method="post
<input type="hidden" id="hiTopicID" name="hiTopicID"
value="{/root/BaseInfo/QueryData/TopicID}" />
<input type="hidden" id="hiTopicAnalysisID" name="hiTopicAnalysisID"
value="{/root/TopicAnalysisbyTopicAnalysisID/TopicAnalysisID}" />
<xsl:value-of select="/root/TopicAnalysisbyTopicAnalysisID/TopicName" />

<xsl:value-of
select="/root/TopicAnalysisbyTopicAnalysisID/TopicDescription" />
Here is the XML data:

<root>

<BaseInfo>

<QueryData>

<m>EditAnalysis</m>

<aid>124</aid>

<t>none</t>

</QueryData>

</BaseInfo>

<PageName>Topics</PageName>

<TopicAnalysisbyTopicAnalysisID>

<TopicID>6</TopicID>

<TopicName>Privacy</TopicName>

<TopicDescription>Testing this out...</TopicDescription>

<topicanalysistextpendingcount>27</topicanalysistextpendingcount>

<answertextpendingcount>36</answertextpendingcount>

<TopicAnalysisID>124</TopicAnalysisID>

<TopicAnalysisText />

<TopicAnalysisTextPending>asdasdasdasdasdasdasdasdasd</TopicAnalysisTextPending>

<AdminUserID>4</AdminUserID>

<TopicQuestionID>4</TopicQuestionID>

<TopicQuestionText>How can you best compete with your competitors?</TopicQuestionText>

<TopicAnswerID>71</TopicAnswerID>

<AnswerTextPending>asdasdasdasdasdasdasdasdasdasdasdasd</AnswerTextPending>

<AnswerText />

</TopicAnalysisbyTopicAnalysisID>

<TopicAnalysisbyTopicAnalysisID>

<TopicID>6</TopicID>

<TopicName>Privacy</TopicName>

<TopicDescription>Testing this out...</TopicDescription>

<topicanalysistextpendingcount>27</topicanalysistextpendingcount>

<answertextpendingcount>42</answertextpendingcount>

<TopicAnalysisID>124</TopicAnalysisID>

<TopicAnalysisText />

<TopicAnalysisTextPending>asdasdasdasdasdasdasdasdasd</TopicAnalysisTextPending>

<AdminUserID>4</AdminUserID>

<TopicQuestionID>3</TopicQuestionID>

<TopicQuestionText>How do you forsee this topic impacting your financial institution in the next year?</TopicQuestionText>

<TopicAnswerID>72</TopicAnswerID>

<AnswerTextPending>asdasdasdasdasdasdasdasdasdasdasdasdasdasd</AnswerTextPending>

<AnswerText />

</TopicAnalysisbyTopicAnalysisID>

<Topics>

<TopicID>1</TopicID>

<IsHotTopic>true</IsHotTopic>

<IsActive>true</IsActive>

<TopicName>Remote Deposit</TopicName>

<TopicDescription>A wave of banks has adopted RDC, and others consider it every day. Has it been profitably for your bank? What best practices have you learned? Which vendors are the best? Is Consumer RDC on your agenda? Share your RDC content, articles, and more.</TopicDescription>

</Topics>

<Topics>

<TopicID>6</TopicID>

<IsHotTopic>false</IsHotTopic>

<IsActive>false</IsActive>

<TopicName>Privacy</TopicName>

<TopicDescription>Testing this out...</TopicDescription>

</Topics>

<Topics>

<TopicID>5</TopicID>

<IsHotTopic>false</IsHotTopic>

<IsActive>false</IsActive>

<TopicName>BSA/AML</TopicName>

<TopicDescription>Testing this out...</TopicDescription>

</Topics>

<Topics>

<TopicID>3</TopicID>

<IsHotTopic>false</IsHotTopic>

<IsActive>false</IsActive>

<TopicName>Reg E ODP</TopicName>

<TopicDescription>The forced opt-out and opt-back-in for ODP is around the corner. Many banks will lose significant revenue, even if they implement a plan. What are your peers doing to soften the blow? What vendors have emerged to help solve this problem? How much revenue can you expect to save? Share your Reg E experiences, and learn what your peers are doing.</TopicDescription>

</Topics>

<Topics>

<TopicID>2</TopicID>

<IsHotTopic>false</IsHotTopic>

<IsActive>false</IsActive>

<TopicName>Social Media</TopicName>

<TopicDescription>Unless you don&#39;t have a radio, TV, computer or any friends, you cannot avoid the exaggerated hype about &quot;social media&quot; and community banks. Should a bank embrace it or block it? Is it all sizzle and no steak? What resources are required to make it work? What are the risks? What are the gains? Share your perspective and learn from what your peers and consultants think.</TopicDescription>

</Topics>

</root>
Here is the c sharp codes:

else if (Request.Form["SaveExistingAnalysis"] != null)
{
cbancWS.TopicAnalysis tan = new cbancWS.TopicAnalysis();
int topicID = Convert.ToInt32(Request.Form["TopicID"]);
if (tan.TopicAnswers == null)
{
tan.TopicAnswers = new string[15];
}
for (int i = 0; i < Request.Form.Count; i++)
{
string x = Request.Form.Keys.ToString();
if (!string.IsNullOrEmpty(x))
{
if (x.Contains("txtA"))
{
tan.TopicAnalysisText = Request.Form[x];
tan.TopicAnalysisTextPending = Request.Form[x];
tan.StatusID = 1;
tan.TopicID = topicID;
tan.AdminUserID = Convert.ToInt32(Request.Form["AdminUserID"]);
tan.TopicAnalysisID = Convert.ToInt32(Request.Form["hiTopicAnalysisID"]);
}
else if (x.Contains("txtQ"))
{
tan.TopicAnalysisText = Request.Form[x];
tan.DateAdded = DateTime.Now;
tan.StatusID = 1;
tan.TopicID = topicID;

TopicAnswer ta = new TopicAnswer();
int qID = GetQuestionNumber(x);
//{TopicAnswerID}
//int aID =
ta.TopicAnswerID = Convert.ToInt32(Request.Form["hiTopicAnswerID"]);
ta.AdminUserID = Convert.ToInt32(Request.Form["AdminUserID"]);
ta.AnswerText = string.Empty;
ta.AnswerTextPending = Request.Form[x];
ta.DateAdded = DateTime.Now;
ta.TopicQuestionID = qID;
ta.TopicAnalysisID = 0;
string swta = cbanc.core.Utility.SerializeObject<TopicAnswer>(ta);
tan.TopicAnswers = swta;
}
}
}
//thisSessionC.BO.AddAnalysis(tan);
XmlData.Append(thisSessionC.BO.GetTopicAnalysis((int)Session["AdminUserID"]).GetXml());
}[/code]
<br/>

View the full article
 
Back
Top