Hello All,
I am having a nightmare trying to add a new row to my
Datagrid. When I use the code below I get the
error: 'Invalid CurrentPageIndex value. It must be >= 0
and < the PageCount. Can anyone help me with this?
Dim dg2 as DataGrid = DG.Items(0).FindControl("dg2")
DSClass = Session("DSClass")
dt = DSClass.Tables(0)
dim dr as DataRow = dt.NewRow ()
dt.Rows.Add(dr)
Session("DSClass") = DSClass
dg2.DataSource = Session("DSClass")
intIndex = dg2.Items.Count ''intIndex = 7
If intIndex >= dg2.PageSize Then ''Page Size = 7
''At present CurrentPageIndex = 0
dg2.CurrentPageIndex = dg2.CurrentPageIndex + 1
intIndex = 0
''CurrentPageIndex = 1 And PageCount = 1
End if
dg2.EditItemIndex = intIndex
dg2.Datasource = Session("DSClass").Tables(0)
dg2.DataBind()
''Errors here because CurrentPageIndex = 1 and needs to be
less than 1, but this is not the page I want to be
displayed? 4 2999
Try setting the CurrentPageIndex to zero before you add the new row.
I encountered the "'Invalid CurrentPageIndex value. It must be >= 0 > and <
the PageCount" in the following scenario.
I bind my DataGrid to my DataSet and go to Page 2. Let's say I rebind to a
new DataSet which would only contain on Page of records, but the DataGrid is
still at Page 2. I'd get the above error.
So before I rebind, I always set the CurrentPageIndex to 0
"Dave" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl... Hello All,
I am having a nightmare trying to add a new row to my Datagrid. When I use the code below I get the error: 'Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. Can anyone help me with this?
Dim dg2 as DataGrid = DG.Items(0).FindControl("dg2") DSClass = Session("DSClass") dt = DSClass.Tables(0) dim dr as DataRow = dt.NewRow () dt.Rows.Add(dr) Session("DSClass") = DSClass dg2.DataSource = Session("DSClass")
intIndex = dg2.Items.Count ''intIndex = 7
If intIndex >= dg2.PageSize Then ''Page Size = 7
''At present CurrentPageIndex = 0
dg2.CurrentPageIndex = dg2.CurrentPageIndex + 1 intIndex = 0
''CurrentPageIndex = 1 And PageCount = 1
End if
dg2.EditItemIndex = intIndex
dg2.Datasource = Session("DSClass").Tables(0) dg2.DataBind() ''Errors here because CurrentPageIndex = 1 and needs to be less than 1, but this is not the page I want to be displayed?
Hi,
Thanks for replying,
I see what you're saying here but when I do this I end up
not editing the row I need,
I need to be editing the first record of the last page,
when I set the current page index to 0 I end up editing
the first record of the first page? -----Original Message----- Try setting the CurrentPageIndex to zero before you add
the new row. I encountered the "'Invalid CurrentPageIndex value. It
must be >= 0 > and <the PageCount" in the following scenario.
I bind my DataGrid to my DataSet and go to Page 2. Let's
say I rebind to anew DataSet which would only contain on Page of records,
but the DataGrid isstill at Page 2. I'd get the above error.
So before I rebind, I always set the CurrentPageIndex to 0
"Dave" <an*******@discussions.microsoft.com> wrote in
messagenews:07****************************@phx.gbl... Hello All,
I am having a nightmare trying to add a new row to my Datagrid. When I use the code below I get the error: 'Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. Can anyone help me with this?
Dim dg2 as DataGrid = DG.Items(0).FindControl("dg2") DSClass = Session("DSClass") dt = DSClass.Tables(0) dim dr as DataRow = dt.NewRow () dt.Rows.Add(dr) Session("DSClass") = DSClass dg2.DataSource = Session("DSClass")
intIndex = dg2.Items.Count ''intIndex = 7
If intIndex >= dg2.PageSize Then ''Page Size = 7
''At present CurrentPageIndex = 0
dg2.CurrentPageIndex = dg2.CurrentPageIndex + 1 intIndex = 0
''CurrentPageIndex = 1 And PageCount = 1
End if
dg2.EditItemIndex = intIndex
dg2.Datasource = Session("DSClass").Tables(0) dg2.DataBind() ''Errors here because CurrentPageIndex = 1 and needs to
be less than 1, but this is not the page I want to be displayed?
.
So you want to add a new record to the DataGrid, and immediately edit it?
Check out this MSDN article section: The Insert Operation http://msdn.microsoft.com/library/de...asp?frame=true
"Dave" <an*******@discussions.microsoft.com> wrote in message
news:33****************************@phx.gbl... Hi, Thanks for replying,
I see what you're saying here but when I do this I end up not editing the row I need, I need to be editing the first record of the last page, when I set the current page index to 0 I end up editing the first record of the first page?
-----Original Message----- Try setting the CurrentPageIndex to zero before you add the new row. I encountered the "'Invalid CurrentPageIndex value. It
must be >= 0 > and <the PageCount" in the following scenario.
I bind my DataGrid to my DataSet and go to Page 2. Let's say I rebind to anew DataSet which would only contain on Page of records, but the DataGrid isstill at Page 2. I'd get the above error.
So before I rebind, I always set the CurrentPageIndex to 0
"Dave" <an*******@discussions.microsoft.com> wrote in messagenews:07****************************@phx.gbl... Hello All,
I am having a nightmare trying to add a new row to my Datagrid. When I use the code below I get the error: 'Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. Can anyone help me with this?
Dim dg2 as DataGrid = DG.Items(0).FindControl("dg2") DSClass = Session("DSClass") dt = DSClass.Tables(0) dim dr as DataRow = dt.NewRow () dt.Rows.Add(dr) Session("DSClass") = DSClass dg2.DataSource = Session("DSClass")
intIndex = dg2.Items.Count ''intIndex = 7
If intIndex >= dg2.PageSize Then ''Page Size = 7
''At present CurrentPageIndex = 0
dg2.CurrentPageIndex = dg2.CurrentPageIndex + 1 intIndex = 0
''CurrentPageIndex = 1 And PageCount = 1
End if
dg2.EditItemIndex = intIndex
dg2.Datasource = Session("DSClass").Tables(0) dg2.DataBind() ''Errors here because CurrentPageIndex = 1 and needs to be less than 1, but this is not the page I want to be displayed?
.
Thanks! -----Original Message----- So you want to add a new record to the DataGrid, and
immediately edit it?Check out this MSDN article section: The Insert Operation http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dndive/html/Data02142002.asp?frame=true
"Dave" <an*******@discussions.microsoft.com> wrote in
messagenews:33****************************@phx.gbl... Hi, Thanks for replying,
I see what you're saying here but when I do this I end
up not editing the row I need, I need to be editing the first record of the last page, when I set the current page index to 0 I end up editing the first record of the first page?
>-----Original Message----- >Try setting the CurrentPageIndex to zero before you add the new row. > >I encountered the "'Invalid CurrentPageIndex value. It must be >= 0 > and < >the PageCount" in the following scenario. > >I bind my DataGrid to my DataSet and go to Page 2.
Let's say I rebind to a >new DataSet which would only contain on Page of
records, but the DataGrid is >still at Page 2. I'd get the above error. > >So before I rebind, I always set the CurrentPageIndex
to 0 > >"Dave" <an*******@discussions.microsoft.com> wrote in message >news:07****************************@phx.gbl... >> Hello All, >> >> I am having a nightmare trying to add a new row to my >> Datagrid. When I use the code below I get the >> error: 'Invalid CurrentPageIndex value. It must be
= 0 >> and < the PageCount. Can anyone help me with this? >> >> Dim dg2 as DataGrid = DG.Items(0).FindControl("dg2") >> DSClass = Session("DSClass") >> dt = DSClass.Tables(0) >> dim dr as DataRow = dt.NewRow () >> dt.Rows.Add(dr) >> Session("DSClass") = DSClass >> dg2.DataSource = Session("DSClass") >> >> intIndex = dg2.Items.Count ''intIndex = 7 >> >> If intIndex >= dg2.PageSize Then ''Page Size = 7 >> >> ''At present CurrentPageIndex = 0 >> >> dg2.CurrentPageIndex = dg2.CurrentPageIndex + 1 >> intIndex = 0 >> >> ''CurrentPageIndex = 1 And PageCount = 1 >> >> End if >> >> dg2.EditItemIndex = intIndex >> >> dg2.Datasource = Session("DSClass").Tables(0) >> dg2.DataBind() >> ''Errors here because CurrentPageIndex = 1 and needs
to be >> less than 1, but this is not the page I want to be >> displayed? >> > > >. >
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Caron |
last post by:
Hi,
In a typical "show-list-click-one-and-edit" scenario, I use a DataGrid on
the "list" page using the pager option. Say I'm on page 2, click edit on an
item and click Cancel on the edit page...
|
by: anon |
last post by:
Hi All,
tried implementing the custom paging solution from 4 guys from
rolla...however the pagecount in my implementation always returns one,
so the postback gives an error asying"CurrentPageIndex...
|
by: Bob Morvay |
last post by:
This should be simple but I am stuck. I am trying to read all the rows of
my datagrid across all the pages. I can read all the rows on the page that
I am on but I can't seem to figure out how to...
|
by: tshad |
last post by:
Is there a way to carry data that I have already read from the datagrid from
page to page?
I am looking at my Datagrid that I page through and when the user says get
the next page, I have to go...
|
by: Franck |
last post by:
Hello,
in a datagrid, in the ItemDataBound event
in some cells a add some javascript that show up an information
strHref.Append("<A onclick=\"popupValid();\">");
strHref.Append("<span...
|
by: Jim Mirra |
last post by:
Hey,
I have been working on this for a while now and I keep getting the same
error.
here is my code:
------- start code ---------
Dim strSQL = "Select tagid,itemid,description,status,...
|
by: Jim Mirra |
last post by:
Hey,
I have been working on this for a while now and I keep getting the same
error.
here is my code:
------- start code ---------
Dim strSQL = "Select tagid,itemid,description,status,...
|
by: Doug Bell |
last post by:
Hi I am still having problems with Tabbing through a DataGrid with a
DataGridComboBox Column.
I need to allow the User to Type the value into the ComboBox so consequently
its ComboBoxStyle is...
|
by: =?Utf-8?B?SnVsaWEgQg==?= |
last post by:
Hi all
Got a weird problem with pagination on a datagrid in asp.net 1.1.
It's populated depending on user selected criteria (it either displays all
or 1 record). It works fine in the...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |