آقا این کد رو ببینید
به طور دستی صفحه دیتاگرد رو عوض میکنم
هیچ جاش مشکلی نداره ولی صفحه عوض نمیشه
این اولین باری نیست که این کارو میکنم
دقیقا با همین روش چند تا صفحه دیگه دارم که مثل هلو کار میکنه
ولی دیگه نمیدونم ایرا این چیه
به طور دستی صفحه دیتاگرد رو عوض میکنم
هیچ جاش مشکلی نداره ولی صفحه عوض نمیشه
این اولین باری نیست که این کارو میکنم
دقیقا با همین روش چند تا صفحه دیگه دارم که مثل هلو کار میکنه
ولی دیگه نمیدونم ایرا این چیه
کد:
Imports System.Data
Imports System.Data.SqlClient
Public Class resault
Inherits System.Web.UI.Page
Dim cn As SqlConnection
Dim cm As SqlCommand
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Dim dr As SqlDataReader
Dim strselect As String
Dim strselect1 As String
Dim startint As Integer
Dim endint As Integer
Dim i As String
Dim ddl1 As String
Dim ddl2 As String
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Dim rb As String
Dim startid As Integer
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
startid = TextBox2.Text
rb = Request.QueryString("where")
ddl1 = Request.QueryString("cat1")
ddl2 = Request.QueryString("cat2")
i = Request.QueryString("search")
cn = New SqlConnection("server=localhost;uid=sa;pwd=123;database=article;")
If Not IsPostBack Then
bindgrid(startid)
End If
End Sub
Sub bindgrid(ByVal startid As Integer)
startid = TextBox2.Text
Dim da As SqlDataAdapter
Dim ds As DataSet
If rb = "artname" Then
Call artname(startid)
Else
If Not ddl1 = -1 And Not ddl2 = -1 Then
strselect = "select top 15 id,artname from article where text like '%" & i & "%' and artcat1 = " & ddl1 & " and artcat2 = " & ddl2 & " and id > " & startid
da = New SqlDataAdapter(strselect, cn)
ds = New DataSet()
da.Fill(ds, "article")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
Else
strselect = "select top 15 id,artname from article where text like '%" & i & "%'" & " and id > " & startid
da = New SqlDataAdapter(strselect, cn)
ds = New DataSet()
da.Fill(ds, "article")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End If
End If
End Sub
Sub artname(ByVal startid As Integer)
startid = TextBox2.Text
Dim da As SqlDataAdapter
Dim ds As DataSet
If Not ddl1 = -1 And Not ddl2 = -1 Then
strselect = "select top 15 id,artname from article where artname like '%" & i & "%' and artcat1 = " & ddl1 & " and artcat2 = " & ddl2 & " and id > " & startid
da = New SqlDataAdapter(strselect, cn)
ds = New DataSet()
da.Fill(ds, "article")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
Else
strselect = "select top 15 id,artname from article where artname like '%" & i & "%'" & " and id > " & startid
da = New SqlDataAdapter(strselect, cn)
ds = New DataSet()
da.Fill(ds, "article")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text += 1
If ddl1 = -1 Then
cm = New SqlCommand("select max(id) from (select top 15 id from article where " & rb & " like '%" & i & "%' and id > " & startid & "order by id) as id", cn)
cn.Open()
TextBox2.Text = cm.ExecuteScalar
cn.Close()
Else
cm = New SqlCommand("select max(id) from (select top 15 id from article where " & rb & " like '%" & i & "%' and artcat1 = " & ddl1 & " and artcat2 = " & ddl2 & "and id > " & startid & "order by id) as id", cn)
cn.Open()
TextBox2.Text = cm.ExecuteScalar
cn.Close()
End If
Page_Load(sender, e)
End Sub
End Class