[RESOLVED] Gridview Paging
I have a web application which does data filtering. The return data set will be bind to Datagridview with Paging set to True.
vb Code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Using connection As New SqlConnection("Data Source=localhost\sqlexpress;Initial Catalog=26may;Integrated Security=SSPI;")
Dim criteria As String = String.Empty
Dim sql As String = "SELECT pk_ddlvryMasterid,pk_ddlvryno as [Dlvry No],convert(varchar,entereddate,106) as Dated" & _
", lpono as LPO_No, Supplier FROM qDDlvryMaster"
Select Case criteriaDropDownList.Text.ToUpper
Case "DLVRY NO" : criteria = "PK_DDLVRYNO"
Case "LPO NO" : criteria = "LPONO"
Case "SUPPLIER" : criteria = "SUPPLIER"
End Select
Using command As New SqlCommand(sql & " where " & criteria & " LIKE @value + '%'", connection)
command.Parameters.Add("@value", Data.SqlDbType.VarChar).Value = valueTextBox.Text.ToString
connection.Open()
Using reader As SqlDataReader = command.ExecuteReader()
Dim tb As New DataTable
tb.Load(reader)
GridView1.DataSource = tb 'set datasource
GridView1.DataBind() 'bind to gridview to view return data set
End Using
End Using
End Using
End Sub
Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles GridView1.PageIndexChanging
GridView1.PageIndex = e.NewPageIndex
GridView1.DataBind()
End Sub
The code works perfectly but every time I move to different page the gridview clear all the rows.
And also how can I make the first gridview column create link to its details page?
Re: [RESOLVED] Gridview Paging
Hey,
I am glad to hear that you got this sorted out.
Out of interest, what was the solution to your problem? It will help other people in the community.
Gary