摘要:觸發GridView內控制項事件抓到當下被選的RowIndex
觸發GridView內控制項事件,DropDowList下拉選擇後,抓到將直傳入另一個TextBox,
Card_NO下拉選單連動Card_ID TextBox欄位
1. GridView + sqlDataSource
2.欄位轉成樣板,新增DropDownList作資料繫結,另一個欄位轉成樣板,新增TextBox
3.新增DropDownList2_SelectedIndexChanged
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
//抓到控制項--因為這是控制項的事件sender就是DropDownList
DropDownList ddl2 = (DropDownList)sender;
GridViewRow gdrow = (GridViewRow)ddl2.NamingContainer;
TextBox tb5 = (TextBox)GridView1.Rows[gdrow.DataItemIndex].FindControl("TextBox5");
tb5.Text = "GA54" + ddl2.SelectedValue.ToString().Substring(2, 3);
}
內容為mis2000Lab學習筆記參考 :
http://www.blueshop.com.tw/board/FUM20041006161839LRJ/BRD201409172008273OL.html