日期:2009-11-02  浏览次数:20536 次

  方法3:显示属于当前访问的一级栏目的二级栏目

  该方法只显示一级栏目下的二级栏目,并不需要实现加粗和改变单元格背景这效果。该方法命名为:showSecondMenu(strNowViewFile)。代码如下:

         public void showSecondMenu(string strNowViewFile)
         {             
              //根据传入的当前该问的文件查找当前访问的栏目名称             
              DataView dvNowMenu = ReadXMLDataView("HeadMenu.XML","LinkUrl = '" + strNowViewFile + "'","OrderID asc");            
              //当前访问的栏目名称
              string strTitle = dvNowMenu[0]["Title"].ToString();
              
              //读取所有属于该栏目的二级栏
              DataView dvSecond = ReadXMLDataView("HeadMenu.XML","Parents = '" + strTitle + "'","OrderID asc");          
 
              if(dvSecond.Count > 0)
              {                           
                   //输出二级栏目              
                   lblCode.Text += "<tr>";
                   lblCode.Text += "<td height='30' class='bgGray1'>";
 
                   for(int i=0; i < dvSecond.Count; i++)
                   {
                       //如果读出来的那条记录的链接地址是当前访问的文件,加粗当前访问的栏目名称并在前面加上·符号
                       if(dvSecond[i]["LinkUrl"].ToString().Trim().Equals(strNowViewFile))
                       {                           
                            lblCode.Text += "&nbsp;&nbsp;·<a href='" + dvSecond[i]["LinkUrl"].ToString().Trim() + "'>";