Hello,
You need to pass filter parameter to XSLT (for filter only selected Institute Course)
<xsl:param name="varInstituteName"></xsl:param>
After then assign this xslt param value using C# XslArgumentList
XsltArgumentList argsList = new XsltArgumentList();
argsList.AddParam("varInstituteName", "", strInstituteName);
Now this Xsl Argument list pass to XML datasource
xmlDS.TransformFile = Server.MapPath("XMLFileCollage.xslt");
xmlDS.TransformArgumentList = argsList;
In xsl file filter parameter
<xsl:if test="InstituteName[node()=$varInstituteName]">
your xslt changes as following way
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="varInstituteName"></xsl:param>
<xsl:template match ="/">
<Institutes>
<xsl:for-each select="Institutes/Institute">
<xsl:if test="InstituteName[node()=$varInstituteName]">
<xsl:for-each select="Course">
<Institute>
<xsl:attribute name="CourseName">
<xsl:value-of select="CourseName/node()"/>
</xsl:attribute>
</Institute>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</Institutes>
</xsl:template>
</xsl:stylesheet>
Bind dropdown logic change as following way
string InstitueName = CollegeDDL.SelectedItem.Value;// "Institute of Business Administration";
XsltArgumentList argsList = new XsltArgumentList();
argsList.AddParam("varInstituteName", "", strInstituteName);
XmlDataSource xmlDS = new XmlDataSource();
xmlDS.EnableCaching = false;
xmlDS.DataFile = Server.MapPath("XMLFileCollage.xml");
xmlDS.TransformFile = Server.MapPath("XMLFileCollage.xslt");
xmlDS.TransformArgumentList = argsList;
xmlDS.XPath = "/Institutes/Institute";
DropDownList1.DataSource = xmlDS;
DropDownList1.DataTextField = "CourseName";
DropDownList1.DataValueField = "CourseName";
DropDownList1.DataBind();
Check it and let me know your feedback
Hope this helpful!
Thanks