Repeater的按鈕取得元件項目/編號
Protected Sub LinkBut_RoleEdit_Click(sender As Object, e As System.EventArgs)
Dim but As LinkButton = CType(sender, LinkButton)
'Dim commandArgument As String = but.CommandArgument
Dim item As RepeaterItem = CType(but.NamingContainer, RepeaterItem)
Dim index As Integer = item.ItemIndex
Dim lb_role_id As Label = Repeater1.Items(index).FindControl("lb_role_id")
End Sub
或
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As System.EventArgs)
Dim index As String = CType(CType(sender, System.Web.UI.WebControls.DropDownList).Parent, RepeaterItem).ItemIndex
Dim v_code As String = CType(Repeater1.Items(index).FindControl("DropDownList1"), DropDownList).SelectedValue
Dim v_remark As TextBox = CType(Repeater1.Items(index).FindControl("tb_remark"), TextBox)
End Sub
DataList按鈕取得元件項目/編號
Dim index As Integer = CType(CType(sender, LinkButton).BindingContainer, DataListItem).ItemIndex
Dim fileType As Label = DataList1.Items(index).FindControl("lb_fileType")
GridView按鈕取得元件項目/編號
Protected Sub but_update_Click(sender As Object, e As System.EventArgs)
Dim index As Integer = CType(CType(sender, System.Web.UI.WebControls.Button).Parent.Parent, GridViewRow).RowIndex
Dim id As Integer = GridView1.DataKeys(index)("menu_id").ToString()
Dim menu_value As String = CType(GridView1.Rows(index).FindControl("tb_menu_value"), TextBox).Text
Dim disabled As String = CType(GridView1.Rows(index).FindControl("cb_EditDisabled_yn"), CheckBox).Checked.ToString
沒有留言:
張貼留言