sach tech

sach tech

  • NA
  • 1
  • 0

Filtering the XML Nodes bound with dropdownlist

May 7 2012 5:43 PM
Hello Friends, I have two DropDownList: 1) CollegeDDL which contains Four static names of the colleges. : Homeopathic Medical College,Physiotherapy College,Institute of Ayurveda,Institute of Business Administration


2) CourseDDL which is bound to CourseDetail.XML.
<?xml version="1.0" encoding="utf-8" ?>
<Institutes>  
 <Institute>
           <InstituteName>  Homoeopathic Medical College  </InstituteName>
  <Course> <CourseName>  BHMS                    </CourseName> </Course>
  <Course> <CourseName>  MD(Repertary)           </CourseName> </Course>
  <Course> <CourseName>  MD(Organon of Medicine) </CourseName> </Course>
  <Course> <CourseName>  MD(Materia Medica)      </CourseName> </Course>
</Institute>

<Institute>
<InstituteName>  Physiotherapy College  </InstituteName>
<Course> <CourseName>  BPT          </CourseName> </Course>
                <Course> <CourseName>  BPT(Sports)  </CourseName> </Course>
                <Course> <CourseName>  BPT(Cardio)  </CourseName> </Course>
</Institute>

<Institute>
<InstituteName>  Institute of Ayurved  </InstituteName>
<Course> <CourseName>  BAMS          </CourseName> </Course>
       <Course> <CourseName>  BAMS(Nature)  </CourseName> </Course>
                <Course> <CourseName>  BAMS(Plants)  </CourseName> </Course>
</Institute>

<Institute>
<InstituteName> Institute of Business Administration </InstituteName>
<Course> <CourseName>BBA</CourseName> </Course>
                <Course> <CourseName>DBM</CourseName> </Course>
                <Course> <CourseName>BBA(Distance)</CourseName> </Course>
</Institute>

---------------------------------
  CourseDetail.XSL
<?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:template match ="/">

    <Institute>
      <xsl:apply-templates select ="Institutes/Institute/Course"/>
    </Institute>

  </xsl:template>


  <xsl:template match ="Institutes/Institute/Course">
    <Institute>
      <xsl:attribute name="CourseName">
        <xsl:value-of select="CourseName"/>
      </xsl:attribute>
    </Institute>

  </xsl:template>

</xsl:stylesheet>
------------------------
I have bind Coursedetail.XML to CourseDDL and CourseDetail.XSL (No XPATH Expression)

After doing this, My CourseDDL is correctly filled with all the CourseName value of my XML file.
But now I want to filter the data bound to CourseDDL , based on College Name selected in CollegeDDL.

For Example:Currently my CourseDDL contains all the CourseName : BHMS,MD(Repertary),MD(Organon of Medicine),......,DBM,BBA(Distance).

But when I select "Homoeopathic Medical College" in CollegeDDL , The data bound to CourseDDL should filter accordingly.
It means when I select "Homoeopathic Medical College" , my CourseDDL should Display only that course: BHMS,MD(Repertary),MD(Organon of Medicine),MD(Materia Medica)

------------------------------------
I have tried the following , but could not achieve it.

1) XmlDataSourceCourse.XPath = "/Institutes/Institute[InstituteName='" + CollegeDDL.SelectedItem.Value + "']"

2) XmlDataSourceCourse.XPath = "/Institutes/Institute[InstituteName='" + CollegeDDL.SelectedItem.Value + "']/Course"

3)XmlDataSourceCourse.XPath = "/Institutes/Institute[InstituteName='" + CollegeDDL.SelectedItem.Value + "']/Course/CourseName"


Anybody please help to format correct XPATH Expression to achive this.