List user control

xiaoxiao2021-03-06  14

Control code:

Public class menu: system.Web.ui.userControl {protected system.Web.ui.WebControls.Datalist DataList1; public string [] value; public int selection = -1; PUBLIC int

Private void page_load (object sender, system.eventargs e) {datalist1.datasource = value; datalist1.selectedIndex = Selection; DataList1.DATABIND ();

}

Quote Binding code: public class mypage: system.Web.ui.page {protected system.web.ui.webcontrols.label label1; protected system.web.ui.webcontrols.datalist DataList1; protected menu Menu1; Protected Menu Menu1;

Private void page_load (object sender, system.eventargs e) {// set DataSource for menu string [] value = new string [] {"news", "events", "reason", "My menu"}; menu1. VALUES = VALUES; STRING SelectionID = Request.Params ["Category"]; if (SelectionID! = ") {INT SelectIndex = Convert.Toint16 (SelectionID); //Menu1.Selection = SelectIndEx; // Select hidden Label1. Text = "Current Selection IS:" VALUES [SelectIndex];

}

转载请注明原文地址:https://www.9cbs.com/read-50178.html

New Post(0)