Dim Bnclick As Button = CType(sender, Button)
Dim GV_row As GridViewRow = CType(Bnclick.NamingContainer, GridViewRow)
Dim GV_Index As Integer = GV_row.RowIndex
Dim Bn As Button = CType(GV_row.FindControl("Bnselect"), Button)
If CType(GV_row.FindControl("Bnselect"), Button).OnClientClick Then
End If
แล้วต้องเขียน Code ในส่วนของ Button หรือ Gridview
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VB.NET
Imports Newtonsoft.Json
Public Class usrCtrl_IC_A1_01_
Inherits System.Web.UI.UserControl
Implements System.Web.UI.ICallbackEventHandler
Public Property curActions() As String
Get
Return ViewState("curActions")
End Get
Set(value As String)
ViewState("curActions") = value
End Set
End Property
Private Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
'ยังไม่ได้กำหนดสิทธิ์การเข้าใช้งาน
Toolbar931.FindControl("Post").Visible = True
Toolbar931.FindControl("AdvSearch").Visible = True
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If curActions Is Nothing Then
curActions = Page.Items("IC_A1")
txtPrefix.Text = curActions
lblWLMD.Text = String.Format("บันทึกแก้ไขรายการ {0} สินค้าคงคลัง [IC_A1_01-RV-001]", (New Dictionary(Of String, String) From
{{"RC", "รับ"}, {"IS", "จ่าย"}, {"AJ", "ปรับปรุง"}})(curActions))
Dim upn As UpdatePanel = Me.Parent.FindControl("upnIC_MainMen")
Dim txtSearch As String = Toolbar931.FindControl("txtSearch").ClientID
Dim txtSearchValue As String = DirectCast(Toolbar931.FindControl("txtSearch"), TextBox).Text
If upn IsNot Nothing Then
Dim obj2Name As String = DirectCast(Me.FindControl("txtTran_TypeDesc"), TextBox).ClientID
Dim strJS As New StringBuilder()
Dim curModule As String = DirectCast(Me.Page.Master.FindControl("TCM_cpCurentModule"), Label).ClientID
Dim curSubModule As String = DirectCast(Me.Page.Master.FindControl("lblcpCurentModule"), Label).ClientID
strJS.Append(" function LookupTab2(tabType, tabCode, event, obj1, obj2Name) {")
strJS.Append(" var p = window.event ? event.keyCode : event.which;")
strJS.Append(" if (p == 9 || p == 38 || p == 40 || p == 37 || p == 39 || p == 36 || p == 35) { return true; }")
strJS.Append(" var obj2;")
strJS.Append(" if (obj2Name == 'lblPart_Desc') {")
strJS.Append(" obj2 = $(obj1).closest('.PartCode').parent().find('.PartName')[0];")
strJS.Append(" } else {")
strJS.Append(" obj2 = document.getElementById(obj2Name);")
'strJS.Append(" obj2 = $('#'+obj2Name);")
strJS.Append(" }")
strJS.Append(" var key = tabType + tabCode + obj1.value.toUpperCase();")
strJS.Append(" WL_ERP.WL_WSLookupTab.GetBasicDataTab(key, PrdSucCallback, PrdFailCallback, obj2);")
strJS.Append(" }")
strJS.Append(" function PrdSucCallback(result, obj) {")
strJS.Append(" obj.value = result ? result : '';") 'IE-OK, FireFox-OK, Chrome-OK
strJS.Append(" }")
strJS.Append(" function PrdFailCallback(result, obj) {")
strJS.Append(" obj.value = '';")
strJS.Append(" }")
strJS.Append(" }")
ScriptManager.RegisterClientScriptBlock(upn, upn.GetType(), New Guid().ToString(), strJS.ToString(), True)
End If
txtTran_Type.Attributes.Add("onkeyup", "LookupTab2('TRN_TAB','" & curActions & "', event, this, '" & txtTran_TypeDesc.ClientID & "');")
txtWarehouse.Attributes.Add("onkeyup", "LookupTab2('WHS_TAB', '" & GetSignOnUserInfo().OrgCode & "', event, this, '" & lblWarehouse.ClientID & "');")
End If
If ViewState("curPage") Is Nothing Then
Call WL_Common.GridManager.SetGridViewInformation(gvrptFormat, {"เลขที่เอกสาร", "วันที่เอกสาร", "คลังสินค้า", "รหัสรายการ", "คำอธิบาย"},
{"Doc_NO", "Doc_Date", "From_WHS", "Tran_Code", "Tran_Desc"},
{"100", "90", "200", "200", "200"},
{"C", "C", "C", "C", "C"},
{"L", "L", "L", "L", "L"},
{"L", "L", "L", "L", "L"})
Dim formatDate As String = "{0:dd-mm-yyyy}"
Dim bf As BoundField
bf = gvrptFormat.Columns(1)
bf.DataFormatString = formatDate
Dim lstH = WL_BLL.ICH.GetListINFO_A(curActions)
ViewState("curPage") = lstH
gvrptFormat.DataSource = lstH.ToList()
gvrptFormat.DataBind()
End If
'ข้อมูลหน่วยนับ
If ViewState("curPage1") Is Nothing Then
ViewState("curPage1") = WL_BLL.UM_Tab.GetList()
End If
AddHandler DirectCast(Me.Parent.Page, IC_MainMenu).btnOKCallBack_Click, AddressOf CallBack_Click
AddHandler DirectCast(Me.Page.Master, WL_ERP_Center_03).mstCheckGridViewDoubleClick, AddressOf GridViewDoubleClick
AddHandler DirectCast(Me.Page, IC_MainMenu).btnOKGetBasicData_Click, AddressOf BrowBasicData
'วางคอนโทรลเอาไว้ที่เดียว IC_MainMenu
AddHandler DirectCast(Me.Page, IC_MainMenu).btnOKCancel_Click, AddressOf oth1_oth2_back3_Click
End Sub
End Class