二级联动[.NET下XML方式]

--获取DataSet[根据SalesSystem_id联动]
select f_id, f_name,SalesSystem_id from dbo.st_productgroup
生成的XML文件如下:
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  
<Table>
    
<f_id>4BD5F32E-FD87-4DB2-9896-013792DED1CD</f_id>
    
<f_name>缇庡绯诲垪.</f_name>
    
<SalesSystem_id>20</SalesSystem_id>
  
</Table>
  
<Table>
    
<f_id>6E9480BA-B890-4A42-85AD-014C1F444575</f_id>
    
<f_name>褰╁绯诲垪锛堢溂閮ㄤ慨楗板嵏濡嗘恫锛?/f_name>
    
<SalesSystem_id>20</SalesSystem_id>
  
</Table>
  
<Table>
    
<f_id>F02ACD12-CAAA-4AE8-9957-0228CFF606F2</f_id>
    
<f_name>鍏朵粬涓汉鎶ょ悊浜у搧</f_name>
    
<SalesSystem_id>7</SalesSystem_id>
  
</Table>
</NewDataSet>
'初始绑定,及写XML文件
 If Not Page.IsPostBack Then
     
Dim myDataSet As DataSet = GetBindDataSet()
     
With Me.selGroupId
       .DataSource 
= myDataSet
       .DataTextField 
= "f_name"
       .DataValueField 
= "f_id"
       .DataBind()
     
End With
     myDataSet.WriteXml(Server.MapPath(
"../Xml/Group2Bind.xml"))
 
End If
<!--.aspx头文件//-->    
<script language="javascript" event="onchange" for="selSalesSystemId_sel">        
    RebindGroup(
this.options[selectedIndex].value);        
</script>
<script language="javascript">
<!--
function ClearSel_Group()
{
    
for (i=frmProduct.selGroupId_sel.length;i>=0;i--)
    {
        frmProduct.selGroupId_sel.remove(i);
        
    }        
}
//-->
</script>
<script language="vbscript">
Function RebindGroup(str)                        
    
dim selDom_Group
    
dim n                
    ClearSel_Group() 
'清除产品组中原先的内容                        
    set cscdom=CreateObject("Msxml2.DOMDocument")
    cscdom.async
=false
    cscdom.load(
"../xml/Group2Bind.xml")
    
set objRoot=cscdom.documentElement
    
set fstlevel=objRoot.childNodes
    
    
If trim(str)<>"" then
        
set selDom_Group=objRoot.selectNodes("/NewDataSet/Table[SalesSystem_id="""& trim(str) &"""]")
    
Else
        
set selDom_Group=objRoot.selectNodes("/NewDataSet/Table")
    
End If
    
    
for n=0 to selDom_Group.length-1
        
set selValue=selDom_Group.item(n).childNodes
        
set oOption = document.createElement("OPTION")
        oOption.text
=selValue.item(1).text
        oOption.value
=selValue.item(0).text
        frmProduct.selGroupId_sel.options.add(oOption)
    
next
End function    
</script>
posted @ 2006-05-22 16:33  blueKnight  Views(453)  Comments(0Edit  收藏  举报