Protected Sub Show_data_combobox_oganizers_run_dc_new()
For i As Integer = 0 To GridView_car_organizers_run_dc_new.Rows.Count - 1
Dim ogzt_id_dc As Label = DirectCast(GridView_car_organizers_run_dc_new.Rows(i).FindControl("ogzt_id_dc_new"), Label) 'รหัส
Dim ogzt_receive_dc As TextBox = DirectCast(GridView_car_organizers_run_dc_new.Rows(i).FindControl("ogzt_receive_dc_new"), TextBox)
Dim ogzt_send_dc As TextBox = DirectCast(GridView_car_organizers_run_dc_new.Rows(i).FindControl("ogzt_send_dc_new"), TextBox)
sb = New StringBuilder()
sb.Append(" SELECT TbCustomer_re.Name_Customer,TbCustomer_se.Name_Customer as Name_Customer_se,run_OGZR")
sb.Append(" from TbEmployee,Tbcar_organizers_run,TbCustomer as TbCustomer_re,TbCustomer as TbCustomer_se")
sb.Append(" where (Tbcar_organizers_run.EmpID=TbEmployee.EmpID)")
sb.Append(" and (Tbcar_organizers_run.receive_OGZR=TbCustomer_re.ID_Customer)")
sb.Append(" and (Tbcar_organizers_run.send_OGZR=TbCustomer_se.ID_Customer)")
'sb.Append(" and (Tbcar_organizers_run.EmpID=@EmpID)")
sb.Append(" and (ID_OGZR=@ID_OGZR)")
sb.Append(" order by ID_OGZR asc")
Dim sqlSear As String
sqlSear = sb.ToString()
com = New SqlCommand()
dtdisID = New DataTable
With com
.Parameters.Clear()
'.Parameters.Add("@EmpID", SqlDbType.NVarChar).Value = cboemp_name_dc_new.SelectedValue.ToString()
.Parameters.Add("@ID_OGZR", SqlDbType.NVarChar).Value = ogzt_id_dc.Text.Trim()
.CommandText = sqlSear
.CommandType = CommandType.Text
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtdisID.Load(dr)
ogzt_receive_dc.Text = dtdisID.Rows(0)("Name_Customer").ToString()
ogzt_send_dc.Text = dtdisID.Rows(0)("Name_Customer_se").ToString()
dr.Close()
Else
ogzt_receive_dc.Text = ""
ogzt_send_dc.Text = ""
dr.Close()
End If
End With
Next
End Sub