Protected Sub Row_Select3(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles GridView3.RowCommand
Dim conse3 As New SqlConnection(ConfigurationManager.ConnectionStrings("LN").ConnectionString)
Dim cmdse3 As New SqlCommand("Select ttimfc010601.t_mser,ttimfc010601.t_mitm FROM ttimfc010601 WHERE ttimfc010601.t_mitm and ttimfc010601.t_mser and ttimfc010601.t_pdno=@se ", conse3)
cmdse3.CommandType = CommandType.Text
Dim currentCommand3 As String = e.CommandName
Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument)
Dim Data As String = GridView3.DataKeys(currentRowIndex).Value
cmdse3.Parameters.Add("@se", SqlDbType.Char).Value = Data
Dim dase As New SqlDataAdapter(cmdse3)
Dim dsse As New DataSet
Dim drse As DataRow
dase.Fill(dsse)
For Each drse In dsse.Tables(0).Rows
Me.TextBox24.Text = ""
Me.TextBox24.Text &= (drse("t_mser"))
Next
conse3.Close()
Me.GridView3.Visible = False
Me.TextBox26.Visible = False
End Sub
Code นะคะ ตารางข้างบนเป็นแค่ตัวอย่างที่ทำให้เห็นภาพนะคะ
ข้อมูลจริงๆ Select มาจาก SQL sever 2005 ค่ะ
Code Select จาก gridview ลงใน textbox ค่ะ
Code (VB.NET)
Protected Sub Row_Select3(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles GridView3.RowCommand
Dim conse3 As New SqlConnection(ConfigurationManager.ConnectionStrings("LN").ConnectionString)
Dim cmdse3 As New SqlCommand("Select ttimfc010601.t_mser,ttimfc010601.t_mitm FROM ttimfc010601 WHERE ttimfc010601.t_mitm and ttimfc010601.t_mser and ttimfc010601.t_pdno=@se ", conse3)
cmdse3.CommandType = CommandType.Text
Dim currentCommand3 As String = e.CommandName
Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument)
Dim Data As String = GridView3.DataKeys(currentRowIndex).Value
cmdse3.Parameters.Add("@se", SqlDbType.Char).Value = Data
Dim dase As New SqlDataAdapter(cmdse3)
Dim dsse As New DataSet
Dim drse As DataRow
dase.Fill(dsse)
For Each drse In dsse.Tables(0).Rows
Me.TextBox24.Text = ""
Me.TextBox24.Text &= (drse("t_mser"))
Next
conse3.Close()
Me.GridView3.Visible = False
Me.TextBox26.Visible = False
End Sub
Code search ค่ะ
Code (VB.NET)
Sub serial2()
Dim conea As New SqlConnection(ConfigurationManager.ConnectionStrings("LN").ConnectionString)
Dim cmdea As New SqlCommand("Select ttimfc010601.t_mser,ttimfc010601.t_mitm FROM ttimfc010601 WHERE ttimfc010601.t_mitm like '%" & Me.TextBox26.Text & "%'", conea)
cmdea.CommandType = CommandType.Text
Dim da As New SqlDataAdapter(cmdea)
Dim ds As New DataSet
da.Fill(ds, "ser1")
Me.GridView3.DataSource = ds.Tables("ser1")
Me.GridView3.DataBind()
conea.Close()
End Sub