Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bubberz
Constraint Violating Yak Guru
289 Posts |
Posted - 2005-12-12 : 14:40:40
|
Here's my scenario:1. Go to last page in datagrid2. Click button to select the checkboxes next to all the rows in the data grid3. Click button to delete all checked items4. Error on page of:Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount5. This doesn't happen if I click the "Delete" button for a row which would be the last record on the last pageBelow is where the error happens, on DataGrid1.DataBind()Sub BuildDataGrid() Dim strSQLDG As StringstrSQLDG = "SELECT ......"'Create the command itemDim sCon1 As New SqlConnectionsCon1.ConnectionString = Session("DBDDL")sCon1.Open()Dim objCmd As New SqlCommand(strSQLDG, sCon1)'Create the DataAdapterDim DA As New SqlDataAdapterDA.SelectCommand [/left]= objCmd'Populate the DataSet and the connectionDim DS As New DataSetDA.Fill(DS)sCon1.Close()'Specifiy DataSource and call DataBind()DataGrid1.DataSource = DSDataGrid1.DataBind()'This is to control if the items deleted were on the last pageIf DataGrid1.Items.Count Mod DataGrid1.PageSize = 1 And _ DataGrid1.CurrentPageIndex = DataGrid1.PageCount - 1 And _ DataGrid1.CurrentPageIndex <> 0 Then DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex - 1End If 'end of controling deleted items on last datagrid pageEnd Sub |
|
bubberz
Constraint Violating Yak Guru
289 Posts |
Posted - 2005-12-12 : 16:58:26
|
Got it with.......'Specifiy DataSource and call DataBind() DataGrid1.DataSource = DS Dim NumberOfItemsChecked As Integer For Each dgI As DataGridItem In DataGrid1.Items NumberOfItemsChecked = NumberOfItemsChecked + 1 Next If DataGrid1.Items.Count Mod DataGrid1.PageSize = NumberOfItemsChecked And _ DataGrid1.CurrentPageIndex = DataGrid1.PageCount - 1 And _ DataGrid1.CurrentPageIndex <> 0 Then DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex - 1 End If DataGrid1.DataBind() |
 |
|
|
|
|