16-08-13, 12:58 PM
السلام عليكم قومت بعمل الكود التالى
و لكن بتحصل مشكلة هنا
هنا بالضبطpos = adsource.PageCount -1
و ده نص المشكلة لى زهقت منو
Object reference not set to an instance of an object.
كود :
Public Sub databinds()
Dim strConnString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection(strConnString)
If ConnectionState.Open Then con.Close()
con.Open()
dadapter = New SqlDataAdapter("select Impression from Table_Ads", con)
dset = New DataSet()
adsource = New PagedDataSource()
dadapter.Fill(dset)
adsource.DataSource = dset.Tables(0).DefaultView
adsource.PageSize = 18
adsource.AllowPaging = True
adsource.CurrentPageIndex = pos
Button4.Enabled = Not adsource.IsFirstPage
Button3.Enabled = Not adsource.IsFirstPage
Button1.Enabled = Not adsource.IsLastPage
Button2.Enabled = Not adsource.IsLastPage
DataList1.DataSource = adsource
DataList1.DataBind()
End Subكود :
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button4.Click
pos = 0
databinds()
End Sub
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
pos = CInt(Me.ViewState("vs"))
pos -= 1
Me.ViewState("vs") = pos
databinds()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
pos = CInt(Me.ViewState("vs"))
pos += 1
Me.ViewState("vs") = pos
databinds()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
pos = adsource.PageCount - 1
databinds()
End Subكود :
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
pos = adsource.PageCount - 1
databinds()
End Subو ده نص المشكلة لى زهقت منو
Object reference not set to an instance of an object.
يَامَعْشَرَ الْجِنِّ وَالإِنسِ إِنْ اسْتَطَعْتُمْ أَنْ تَنفُذُوا مِنْ أَقْطَارِ السَّمَاوَاتِ وَالأَرْضِ فَانفُذُوا لا تَنفُذُونَ إِلاّ بِسُلْطَانٍ(33) سورة الرحمن
