https://imgur.com/a/ZuReR3r
After clicking on the button the datatable features are display but when the page loads the features are not displayed
https://imgur.com/a/u3bPXkA
Imports System.Data
Imports System.Web.Services
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Threading
Public Class DriverDetails1
Inherits System.Web.UI.Page
Dim conString As String = ConfigurationManager.ConnectionStrings("STMISWEBConnectionString").ConnectionString
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Bindroute()
gvCustomers.DataBind()
End If
End Sub
Private Sub Bindroute()
Dim cmdt As New SqlCommand("SELECT * FROM DriverDetails")
gvCustomers.DataSource = Me.ExecuteQuery(cmdt, "SELECT")
gvCustomers.DataBind()
'Required for jQuery DataTables to work.
'gvCustomers.UseAccessibleHeader = True
'gvCustomers.FooterRow.TableSection = TableRowSection.TableFooter
gvCustomers.HeaderRow.TableSection = TableRowSection.TableHeader
End Sub
Protected Sub gvCustomers_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles gvCustomers.RowCommand
If e.CommandName = "Edit1" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = gvCustomers.Rows(index)
Dim Singles As Label = CType(row.FindControl("Singles"), Label)
Dim Doubles As Label = CType(row.FindControl("Doubles"), Label)
Dim Entrycode As Label = CType(row.FindControl("Entrycode"), Label)
Dim Routes As Label = CType(row.FindControl("Routes"), Label)
Singlek.Text = Singles.Text
Doublesk.Text = Doubles.Text
EntryCodeK.Text = Entrycode.Text
FRoute0.Text = Routes.Text
If Not IsPostBack Then Bindroute()
' Exit Sub
End If
End Sub
Private Function ExecuteQuery(ByVal cmd As SqlCommand, ByVal action As String) As DataTable
'Dim conString As String = conString
Using con As New SqlConnection(conString)
cmd.Connection = con
Select Case action
Case "SELECT"
Using sda As New SqlDataAdapter()
sda.SelectCommand = cmd
Using dt As New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
Case "UPDATE"
con.Open()
cmd.ExecuteReader()
con.Close()
Exit Select
End Select
Return Nothing
End Using
End Function
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If String.IsNullOrEmpty(Singlek.Text) Then
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('You Must indicate the Single Route Charges by Selecting from the List');", True)
Singlek.Focus()
Exit Sub
Else
If String.IsNullOrEmpty(Doublesk.Text) Then
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('You Must indicate the Double Route Charges by Selecting from the List');", True)
Doublesk.Focus()
Exit Sub
Else
If String.IsNullOrEmpty(FRoute0.Text) Then
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('You Must indicate the Route Name by Selecting from the List');", True)
FRoute0.Focus()
Exit Sub
End If
End If
End If
Dim sqlConnection12 As New SqlConnection(conString)
Dim objCommand22 As SqlCommand = New SqlCommand()
Dim cmd2 As New SqlCommand
cmd2.CommandText = "dRIVEREdit"
cmd2.CommandType = CommandType.StoredProcedure
cmd2.Connection = sqlConnection12
cmd2.Parameters.Add("@sj", SqlDbType.NVarChar, 150).Value = Singlek.Text
cmd2.Parameters.Add("@cal", SqlDbType.NVarChar, 50).Value = DropDownList1.SelectedItem.Text
cmd2.Parameters.Add("@r", SqlDbType.NVarChar, 350).Value = FRoute0.Text
cmd2.Parameters.Add("@k", SqlDbType.Int).Value = EntryCodeK.Text
sqlConnection12.Open()
cmd2.ExecuteReader()
sqlConnection12.Close()
Singlek.Text = ""
Doublesk.Text = ""
FRoute0.Text = ""
EntryCodeK.Text = ""
If Not IsPostBack Then Bindroute()
' Response.Redirect(Request.Url.AbsoluteUri)
' ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('Route Updated Successfully');", True)
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "showalert", "alert('Record Updated Successfully');window.location ='" + Request.Url.AbsoluteUri + "';", True)
Exit Sub
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs)
Dim txtsingle As String = DirectCast(gvCustomers.FooterRow.FindControl("fsingle"), TextBox).Text
Dim txtdouble As String = DirectCast(gvCustomers.FooterRow.FindControl("fdouble"), TextBox).Text
Dim txtRoute As String = DirectCast(gvCustomers.FooterRow.FindControl("froute"), TextBox).Text
Dim txtVtype As String = DirectCast(gvCustomers.FooterRow.FindControl("Vtype"), TextBox).Text
Dim txtAddParticulars As TextBox = CType(gvCustomers.FooterRow.FindControl("fsingle"), TextBox)
Dim txtAddParticulars2 As TextBox = CType(gvCustomers.FooterRow.FindControl("fdouble"), TextBox)
Dim txtAddParticulars3 As TextBox = CType(gvCustomers.FooterRow.FindControl("froute"), TextBox)
'Dim txtVtype As TextBox = CType(gvCustomers.FooterRow.FindControl("Vtype"), TextBox)
If String.IsNullOrEmpty(txtsingle) Then
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('You Must indicate the Veichle Number Plate');", True)
txtAddParticulars.Focus()
Exit Sub
Else
If String.IsNullOrEmpty(txtdouble) Then
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('You Must indicate the Route Charges');", True)
txtAddParticulars2.Focus()
Exit Sub
Else
If String.IsNullOrEmpty(txtVtype) Then
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('You Must indicate the Veichle Type');", True)
txtAddParticulars3.Focus()
Exit Sub
End If
End If
End If
Dim sqlConnection12 As New SqlConnection(conString)
Dim objCommand22 As SqlCommand = New SqlCommand()
Dim cmd2 As New SqlCommand
cmd2.CommandText = "PushdRIVERS"
cmd2.CommandType = CommandType.StoredProcedure
cmd2.Connection = sqlConnection12
cmd2.Parameters.Add("@sj", SqlDbType.NVarChar, 150).Value = txtdouble
cmd2.Parameters.Add("@cal", SqlDbType.NVarChar, 50).Value = txtsingle
cmd2.Parameters.Add("@r", SqlDbType.NVarChar, 350).Value = txtVtype
cmd2.Parameters.Add("@k", SqlDbType.NVarChar, 350).Value = txtRoute
sqlConnection12.Open()
cmd2.ExecuteReader()
sqlConnection12.Close()
' ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('Route Added Successfully');", True)
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "showalert", "alert('Route Added Successfully');window.location ='" + Request.Url.AbsoluteUri + "';", True)
txtAddParticulars.Text = ""
txtAddParticulars2.Text = ""
txtAddParticulars3.Text = ""
If Not IsPostBack Then Bindroute()
Exit Sub
End Sub
Protected Sub DeleteCustomer(ByVal sender As Object, ByVal e As EventArgs)
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
Using Con As New SqlConnection(conString)
Con.Open()
Using cmd As New SqlCommand
cmd.Connection = Con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "DelsingleVeichleitem"
cmd.Parameters.Add("@t", SqlDbType.NVarChar).Value = lnkRemove.CommandArgument
cmd.ExecuteReader()
Con.Close()
End Using
End Using
'BindItemList()
If Not IsPostBack Then Bindroute()
Response.Redirect(Request.Url.AbsoluteUri)
Exit Sub
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Response.Redirect(String.Format("~/FormsV2/Dashboardloader.aspx"))
End Sub
Protected Sub OnPaging(sender As Object, e As GridViewPageEventArgs)
gvCustomers.PageIndex = e.NewPageIndex
Me.SearchCustomers()
End Sub
Private Sub SearchCustomers()
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand()
Dim sql As String = "SELECT atk, DriverName, Vtype, Vplate FROM DriverDetails"
If Not String.IsNullOrEmpty(txtSearch.Text.Trim()) Then
sql += " WHERE DriverName LIKE @ContactName + '%'"
cmd.Parameters.AddWithValue("@ContactName", txtSearch.Text.Trim())
End If
cmd.CommandText = sql
cmd.Connection = con
Using sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
gvCustomers.DataSource = dt
gvCustomers.DataBind()
End Using
End Using
End Using
End Sub
Protected Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
SearchCustomers()
End Sub
End Class