1
LinkButton LinkButton 連 Button Text Visible Click
HyperLink HyperLink 來 立 連 Text ImageUrl ( ) NavigateUrl 連 Target 連 _blank _parent frameset _search _self 連 _top
例 sample2-a1 易 連 private void Page_Load(object sender, System.EventArgs e) { yahoohl.navigateurl = "http://tw.yahoo.com"; yahoohl.target = "_blank"; }
Image Image 來 ImageUrl AlternateText Height Width Height Width
練 sample2-b1 念 利 ImageUrl 來更 Image
ImageButton ImageButton Button ImageUrl AlternateText Click ( 理 參數 滑 )
例 sample2-a2 (1) 利 onmouseover onmouseout HTML <asp:imagebutton onmouseover="this.src='carlogo.jpg' " onmouseout="this.src='cartext.jpg' "
例 sample2-a2 (2) WebForm1.aspx private void carib_click(object sender, System.Web.UI.ImageClickEventArgs e) { if(e.x<=100) textlb.text = " 來 BMW!!"; else textlb.text = " 來 BENZ!!"; }
練 sample2-b2 念 數 Label Label Visible false 數 Cookie Session
DropDownList DropDownList 拉 Items 拉 (items ListItemCollection 類 ) ( ListItem 類 ) AutoPostBack 更 SelectedIndexChanged 更 ( AutoPostBack true)
ListItemCollection 類 DropDownList items ListItemCollection 類 () 索 ex DropDownList1.Items[1] Count ListItem 數 SelectedItem SelectedIndex 索 Add (ListItem string) Clear Remove (ListItem string) RemoveAt 索 (int)
ListItem 類 ListItemCollection 類 ListItem 類 Text Value 聯 Selected
例 sample2-a3 (1) struct star { public string name; public string country; public string imgurl; }
例 sample2-a3 (2) star[] mystar = new star[3]; private void Page_Load(object sender, System.EventArgs e) { mystar[0].name = "S.H.E"; mystar[0].country = ""; mystar[0].imgurl = "she.jpg"; mystar[1].name = " "; mystar[1].country = ""; mystar[1].imgurl = ".jpg";
例 sample2-a3 (3) mystar[2].name = " "; mystar[2].country = " "; mystar[2].imgurl = ".jpg"; } if(!ispostback) { foreach(star staritem in mystar) starddl.items.add(staritem.name); starddl.autopostback = true; changeinfo(); }
例 sample2-a3 (4) private void starddl_selectedindexchanged(object sender, System.EventArgs e) { changeinfo(); } private void changeinfo() { namelb.text = mystar[starddl.selectedindex].name; countrylb.text = mystar[starddl.selectedindex].country; pictureimg.imageurl = mystar[starddl.selectedindex].imgurl; }
ListBox ListBox DropDownList Items ( ListItemCollection 類 ) SelectionMode Single Multiple ( 利 Selected true)
例 sample2-a4 (1) private void purchasebtn_click(object sender, System.EventArgs e) { shoppinglb.items.add(itemlb.selecteditem); itemlb.items.remove(itemlb.selecteditem); shoppinglb.selectedindex = -1; totallb.text = total().tostring(); }
例 sample2-a4 (2) private void cancelbtn_click(object sender, System.EventArgs e) { itemlb.items.add(shoppinglb.selecteditem); shoppinglb.items.remove(shoppinglb.selecteditem); itemlb.selectedindex = -1; totallb.text = total().tostring(); }
例 sample2-a4 (3) private int total() { int sum = 0; foreach(listitem item in shoppinglb.items) { sum += int.parse(item.value); } return sum; }
練 sample2-b3 類 拉 說 神 龍 C# JAVA 料 料理 料理 料理
CheckBox CheckBox Text TextAlign Checked CheckedChanged 狀 ( AutoPostBack true)
CheckBoxList CheckBoxList Items ( ListItemCollection 類 ) RepeatColumns 料欄 數 RepeatDirection SelectedIndexChanged 更 ( AutoPostBack true)
RadioButton RadioButton Text TextAlign Checked GroupName CheckedChanged 狀 ( AutoPostBack true)
RadioButtonList RadioButton 來 立 Items ( ListItemCollection 類 ) RepeatColumns 料欄 數 RepeatDirection SelectedIndexChanged 更 ( AutoPostBack true)
例 sample2-a5 (1) 料 WebForm1.aspx private void submitbtn_click(object sender, System.EventArgs e) { Session.Add("name",nameTB.Text); Session.Add("sex",sex1RB.Checked?"":""); Session.Add("education", educationrbl.selecteditem.text);
例 sample2-a5 (2) WebForm1.aspx string hobby = ""; foreach(listitem item in hobbycbl.items) if(item.selected) hobby+= item.text +" "; if(hobby == "") hobby = " "; Session.Add("hobby", hobby); } Response.Redirect("WebForm2.aspx");
例 sample2-a5 (3) WebForm2.aspx private void Page_Load(object sender, System.EventArgs e) { Response.Write(Session["name"].ToString()); Response.Write(Session["sex"].ToString() + "!!<br>"); Response.Write(" 歷 "+Session["education"].ToString() + "<br>"); Response.Write(" "+Session["hobby"].ToString()); }
練 sample2-b4 念 ListItem Value
Access 料 (1) 立 料 [] [] [ 料 ]
立 料 Access 料 (2) 料 [ 立 料 ]
Access 料 (3) 料 料 料 料 料 料 欄
ADO.NET ADO.NET.NET Framework 類 來 料 料 料 料 料 Ex MSSQL Access Excel XML ADO.NET 連
.NET 料.NET 料 料來 類.NET Data Provider SQL.NET Data Provider System.Data.SqlClient 料 MS-SQL OLE DB.NET Data Provider System.Data.OleDb 料 Dbase FoxPro Excel Access Oracle Access ODBC.NET Data Provider 料 MySQL
DataAdapter DataAdapter 料來 DataSet Fill 料來 料 料 Update 更 料來 料
利 DataAdapter 立連 (1) 料類 類 拉 DataAdapter 精靈
利 DataAdapter 立連 (2) 連 來 立連
利 DataAdapter 立連 (3) ACCESS 料 Microsoft Jet 4.0 OLE DB Provider
利 DataAdapter 立連 (4) 連 料來 連
利 DataAdapter 立連 (5) 連 連 錄
利 DataAdapter 立連 (6) SQL
利 DataAdapter 立連 (7) SQL 來 行 SQL
利 DataAdapter 立連 (8) 料
利 DataAdapter 立連 (9) 欄 SQL
利 DataAdapter 立連 (10) DataAdapter
利 DataAdapter 立連 (11) DataAdapter 立 DataSet ( 料 )
利 DataAdapter 立連 (12) DataSet ( 料 ) 利 DataAdapter Fill DataSet
DataGrid (1) DataGrid 料 料 DataSource 料來 AutoGenerateColumns 料欄 Columns 欄 DataBind 行 料
DataGrid (2) DataSet 料 DataGrid DataSource DataSet 利 DataAdapter Fill 料來 料 DataSet 利 DataGrid DataBind 行 料
例 sample2-a6 料 DataGrid private void Page_Load(object sender, System.EventArgs e) { oledbdataadapter1.fill(dataset11); DataGrid1.DataBind(); }
練 sample2-b5 料 立 料 欄 料 DataGrid 念 利 DataAdapter 立 連
料行類 料行 料來 欄 料行 立 理 料 連 料行 料行 連 料行 利 來
料行 料行 來 料來 欄 料 DataGrid 欄 料欄 料來 欄
料行 料行 更 ( ) 欄 料 () SelectedIndexChanged 狀 利 SelectedItem 料列
DataGrid 料 DataGrid 料 Items Cells 來 Items DataGrid 料列 Cells 料列 列 欄 料 DataGrid1.Items[1].Cells[3].Text;
例 sample2-a7 DataGrid 金 private void Page_Load(object sender, System.EventArgs e) { oledbdataadapter1.fill(dataset11); DataGrid1.DataBind(); int total = 0; foreach(datagriditem item in DataGrid1.Items) total += int.parse(item.cells[1].text); totallb.text = total.tostring(); }
練 sample2-b6 料 立 料 數 欄 欄 列 料 念 利 料行來 料 AutoGenerateColumns false
連 料行 連 料行 料行 連 ( ) 欄 料 () URL 欄 連 URL 串 列參數 若 URL WebForm2.aspx?filename={0} URL 欄 料 {0}
例 sample2-a8 private void Page_Load(object sender, System.EventArgs e) { oledbdataadapter1.fill(dataset11); favoritedg.databind(); }
練 sample2-b7 料 立 料 欄 連 料行 連 WebForm2.aspx 列 念 URL 串 URL 欄 料 列參數
料行 料行 ( ) 欄 料 () 令 行 令 (CommandName) 料行 ItemCommand ItemCommand 料列 參數 e DataGrid 料行 令 來 EnableViewState false
例 sample2-a9 private void Page_Load(object sender, System.EventArgs e) { oledbdataadapter1.fill(dataset11); itemdg.databind(); } private void itemdg_itemcommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { shoppinglb.items.add(e.item.cells[1].text+ " " +e.item.cells[2].text); totallb.text = (int.parse(totallb.text) + int.parse(e.item.cells[2].text)).tostring(); }
練 sample2-b8 料 立 料 金 欄 sample2-a9 念 利 CommandName 來 Items FindByText
DataGrid 料 數 利 來 料 利 (AllowPaging) true (PageSize) 料 數 利 PageIndexChanged 參數 e NewPageIndex DataGrid CurrentPageIndex 行
練 sample2-b9 料 立 料 欄 料 利 料 料 念 利 PageIndexChanged 參數來 DataGrid CurrentPageIndex