欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

DataList嵌套DataList的實現

系統 1922 0
數據服務控件的嵌套最主要的是是內層控件數據的加載和事件的觸發。 DataList嵌套的重點是要在外層DataList的ItemDataBound事件中用e.Item.FindControl方法來找到嵌套層 DataList的id,編寫嵌套層DataList的綁定數據源事件。下面以兩層DataList為例介紹下實現的過程。效果如下圖:

---------前臺html代碼-------

  1. < asp:datalist id = "dlFileType" RepeatColumns = "2" runat = "server" >
  2. < ItemTemplate >
  3. < table border = "0" cellspacing = "0" cellpadding = "0" >
  4. < tr >
  5. < td width = "22%" height = "88" align = "center" valign = "top" >
  6. < img src = '<%#DataBinder.Eval(Container.DataItem,"cnvcPicURL")%>' width = "80" height = "80" >
  7. </ td >
  8. < td valign = "top" >
  9. < table width = "96%" border = "0" cellpadding = "0" cellspacing = "0" >
  10. < tr width = "100%" >
  11. < td colspan = "2" > < img src = '<%#PageBase.strStyleRoot+"/picture/pic_fwzn_08.gif"%>' height = "20" > < %#DataBinder.Eval(Container.DataItem,"cnvcTitle")% >
  12. < asp:Label id = "labFileType" runat = "server" Visible = False Text = '<%#DataBinder.Eval(Container.DataItem,"cniFileTypeID")%>' >
  13. </ asp:Label > </ td >
  14. </ tr >
  15. < tr >
  16. < td width = "300" >
  17. < asp:DataList id = "dlFileList" runat = "server" RepeatColumns = "1" Width = "100%" >
  18. < ItemTemplate >
  19. < TABLE cellSpacing = "1" cellPadding = "1" width = "100%" border = "0" >
  20. < tr >
  21. < td width = "7%" height = "20" align = "center" >
  22. < img src = '<%#PageBase.strStyleRoot+"/picture/pic_fwzn_dot.gif"%>' width = "3" height = "3" > </ td >
  23. < td width = "93%" >
  24. < font color = "#393939" >
  25. < %#GetTitle((string)Convert.ToString(DataBinder.Eval(Container.DataItem,"cnvcTitle")),(string)Convert.ToString(DataBinder.Eval(Container.DataItem,"cnvcFileType")),(string)Convert.ToString(DataBinder.Eval(Container.DataItem,"cniBaseFileID")),(DateTime)DataBinder.Eval(Container.DataItem,"cndtPublishTime"))% >
  26. </ font >
  27. </ td >
  28. </ tr >
  29. </ TABLE >
  30. </ ItemTemplate >
  31. </ asp:DataList >
  32. </ td >
  33. </ tr >
  34. < tr >
  35. < td colspan = "2" bgcolor = "E6E6E6" height = "1" > < img src = '<%#PageBase.strStyleRoot+"/picture/1X1.gif"%>' width = "1" > </ td >
  36. </ tr >
  37. < tr align = "center" >
  38. < td height = "22" colspan = "2" > < a href = "#" title = "可查看到更多相關內容" > < img src = '<%#PageBase.strStyleRoot+"/picture/more.gif"%>' width = "34" height = "11" border = "0" > </ a > </ td >
  39. </ tr >
  40. </ table >
  41. </ td >
  42. </ tr >
  43. </ table >
  44. </ ItemTemplate >
  45. </ asp:datalist >

--------后臺cs代碼------
內層控件數據綁定與事件聲明在外層的ItemDataBind中實現
  1. private void dlFileType_ItemDataBound( object sender,System.Web.UI.WebControls.DataListItemEventArgse)
  2. {
  3. if (e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
  4. {
  5. DataListdl= null ;
  6. LabellabTypeID= null ;

  7. dl=(DataList)e.Item.FindControl( "dlFileList" )
  8. labTypeID=(Label)e.Item.FindControl( "lbFileType" );
  9. string typeID=labTypeID.Text.ToString();
  10. int iTypeID=Convert.ToInt32(typeID);
  11. string commandText= "select*fromtbfile" ;
  12.     commandText=commandText+ "WhereTypeID=" +iTypeID;
  13. //------------
  14. string connString=ConfigurationSettings.AppSettings[ "dsn" ];
  15. SqlConnectionconn= new SqlConnection();
  16.     conn.ConnectionString=connString;
  17.     conn.Open();
  18.     SqlDataAdaptermyCommand= new SqlDataAdapter(commandText,conn);
  19.     DataSetds= new DataSet();
  20.     myCommand.Fill(ds, "tbFile" );
  21.     conn.Close();
  22. //------------
  23. dl.DataSource=ds.Tables[ "tbFile" ];;
  24. dl.DataBind();
  25. }
  26. }

DataList嵌套DataList的實現


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 午夜亚洲| 精品国产18久久久久久二百 | 正在播放国产无套露脸 | 欧美久久久久久 | 免费黄色a视频 | 丁香婷婷激情 | 99视频在线精品 | 国产精品久久人妻无码网站蜜臀 | 色视频在线免费观看 | 国产精品亲子伦av一区二区三区 | 日韩乱视频 | 亚洲另类自拍 | 九色视频自拍 | 欧美日韩亚洲人人夜夜澡 | 日本护士xxxxx极品 | 东方亚洲东方欧美色二区 | 日韩国产精品一区二区三区 | 免费一级在线 | 国产农村妇女毛片精品久久麻豆 | 亚洲免费观看在线视频 | 日韩av免费在线观看 | 欧美精品欧美极品欧美激情 | 日韩丝袜在线观看 | 99久久精品费精品国产一区二区 | 日韩成人高清 | 一道本在线观看视频 | 夜夜夜久久久 | 91精品国产综合久久欧美 | 久久夜夜操妹子 | 久久亚洲国产成人亚 | 亚洲免费视频在线观看 | 九九亚洲视频 | 国产成人18黄网站免费 | 欧美日本日韩aⅴ在线视频 日韩福利视频导航 | 99久久精品国产亚洲 | 色狠狠色狠狠综合天天 | 色综合综合在线 | 狠狠干天天 | 超碰av在线| 免费一级毛片在线播放视频 | 亚洲一区二区三 |