Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid with EnableViewState="false"

Status
Not open for further replies.

tsp1lrk

IS-IT--Management
May 30, 2001
103
US
Hello!

I have been EVERYWHERE without a solid answer- not sure what is going on. I have a Datagrid, EnableViewState="false"- I want to use paging. I have seen articles everywhere on how to make this work. It seems like it works locally, when I put it out on a development server, the first page loads, when I click on say, page 5 the page is blank! I have the grid binding too on PageIndexChanged; not sure what is wrong. Here is some code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not ViewState("CurrentPageIndex") Is Nothing Then
DataGrid1.CurrentPageIndex = ViewState("CurrentPageIndex")
End If
BindGrid()

End Sub

Private Sub BindGrid()
Dim cnn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet

cnn = New SqlConnection(ConfigurationSettings.AppSettings().Item("ConnectionString"))
da = New SqlDataAdapter("select Appropriation, PAR, Username, ProjectName , 'ViewInfo.aspx?APPID=' +Appropriation AS URL from tblAppropriation", cnn)
da.Fill(ds, "tblAppropriation")
DataGrid1.DataSource = ds.Tables("tblAppropriation").DefaultView
DataGrid1.DataSource = ds
DataGrid1.DataMember = "tblAppropriation"
DataGrid1.DataBind()

End Sub



Sub Datagrid1_PageIndexChanged(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
ViewState("CurrentPageIndex") = e.NewPageIndex
BindGrid()


End Sub

Not sure why my page is blank when I want to navigate to another page- HELP!

Thanks,
Lisa
 
Just a guess... try putting the If Not IsPostback in the Page Load Event to only run if it is not a postback.

Hope everyone is having a great day!

Thanks - Jennifer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top