473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Deleting row from GridView causes ArgumentOutOfRangeException during System.Web.UI.WebControls.GridView.set_SelectedInd ex(Int32 value)

Hi All,

I am using Link Button for DELETE on the gridview. When I click on
DELETE link, I get the ArgumentOutOfRangeException. But...it deletes
the record from table in the database.
On Gridview_rowdatabound, I am dynamically building hyperlink control
based on the values in the other fields. Here is my code for
Gridview_rowdatabound. It does work sometimes though.
Protected Sub dgQuestions_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
dgQuestions.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

Dim hLnk As HyperLink = CType(e.Row.Cells(3).Controls(0),
HyperLink)

Dim iCID As String
iCID = drpClasses.SelectedValue
Dim iQSeq As Integer
iQ = cint(e.Row.Cells(1).Text)
hLnk.NavigateUrl = "ShowDetails.aspx?CID=" & iCID

End If
End Sub

Please, see Stack Trace below. Any ideas anyone?

Stack Trace:

[ArgumentOutOfRangeException: Specified argument was out of the range
of valid values.
Parameter name: value]
System.Web.UI.WebControls.GridView.set_SelectedInd ex(Int32 value)
+1454311
System.Web.UI.WebControls.GridView.HandleDeleteCal lback(Int32
affectedRows, Exception ex) +354
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary
oldValues, DataSourceViewOperationCallback callback) +123
System.Web.UI.WebControls.GridView.HandleDelete(Gr idViewRow row,
Int32 rowIndex) +927
System.Web.UI.WebControls.GridView.HandleEvent(Eve ntArgs e, Boolean
causesValidation, String validationGroup) +1155
System.Web.UI.WebControls.GridView.OnBubbleEvent(O bject source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEven t(Object source,
EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)
+115
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String
eventArgument) +163

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+174
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5102

Jun 28 '06 #1
2 3442
Use a template column and a generic hyperlink button to achieve your
ShowDetails goal.

Here is the cause of your problems:

System.Web.UI.WebControls.GridView.HandleDeleteCal lback(Int32
affectedRows, Exception ex)
You can create a new hyperlink in real time and add it to your cell.

e.Row.Cells(3).Controls.Add(hyperlink) in ex.

loga123 wrote: Hi All,

I am using Link Button for DELETE on the gridview. When I click on
DELETE link, I get the ArgumentOutOfRangeException. But...it deletes
the record from table in the database.
On Gridview_rowdatabound, I am dynamically building hyperlink control
based on the values in the other fields. Here is my code for
Gridview_rowdatabound. It does work sometimes though.
Protected Sub dgQuestions_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
dgQuestions.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

Dim hLnk As HyperLink = CType(e.Row.Cells(3).Controls(0),
HyperLink)

Dim iCID As String
iCID = drpClasses.SelectedValue
Dim iQSeq As Integer
iQ = cint(e.Row.Cells(1).Text)
hLnk.NavigateUrl = "ShowDetails.aspx?CID=" & iCID

End If
End Sub

Please, see Stack Trace below. Any ideas anyone?

Stack Trace:

[ArgumentOutOfRangeException: Specified argument was out of the range
of valid values.
Parameter name: value]
System.Web.UI.WebControls.GridView.set_SelectedInd ex(Int32 value)
+1454311
System.Web.UI.WebControls.GridView.HandleDeleteCal lback(Int32
affectedRows, Exception ex) +354
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary
oldValues, DataSourceViewOperationCallback callback) +123
System.Web.UI.WebControls.GridView.HandleDelete(Gr idViewRow row,
Int32 rowIndex) +927
System.Web.UI.WebControls.GridView.HandleEvent(Eve ntArgs e, Boolean
causesValidation, String validationGroup) +1155
System.Web.UI.WebControls.GridView.OnBubbleEvent(O bject source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEven t(Object source,
EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)
+115
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String
eventArgument) +163

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+174
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5102

Jun 28 '06 #2
Hi John,

Thanks for your reply.
I tried your suggestion...but still have the same problem. I am not
sure why I have such problem.
Any help is greatly appreciated.

Thanks in advance.
John Prado wrote:
Use a template column and a generic hyperlink button to achieve your
ShowDetails goal.

Here is the cause of your problems:

System.Web.UI.WebControls.GridView.HandleDeleteCal lback(Int32
> affectedRows, Exception ex)


You can create a new hyperlink in real time and add it to your cell.

e.Row.Cells(3).Controls.Add(hyperlink) in ex.

loga123 wrote:
Hi All,

I am using Link Button for DELETE on the gridview. When I click on
DELETE link, I get the ArgumentOutOfRangeException. But...it deletes
the record from table in the database.
On Gridview_rowdatabound, I am dynamically building hyperlink control
based on the values in the other fields. Here is my code for
Gridview_rowdatabound. It does work sometimes though.
Protected Sub dgQuestions_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
dgQuestions.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

Dim hLnk As HyperLink = CType(e.Row.Cells(3).Controls(0),
HyperLink)

Dim iCID As String
iCID = drpClasses.SelectedValue
Dim iQSeq As Integer
iQ = cint(e.Row.Cells(1).Text)
hLnk.NavigateUrl = "ShowDetails.aspx?CID=" & iCID

End If
End Sub

Please, see Stack Trace below. Any ideas anyone?

Stack Trace:

[ArgumentOutOfRangeException: Specified argument was out of the range
of valid values.
Parameter name: value]
System.Web.UI.WebControls.GridView.set_SelectedInd ex(Int32 value)
+1454311
System.Web.UI.WebControls.GridView.HandleDeleteCal lback(Int32
affectedRows, Exception ex) +354
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary
oldValues, DataSourceViewOperationCallback callback) +123
System.Web.UI.WebControls.GridView.HandleDelete(Gr idViewRow row,
Int32 rowIndex) +927
System.Web.UI.WebControls.GridView.HandleEvent(Eve ntArgs e, Boolean
causesValidation, String validationGroup) +1155
System.Web.UI.WebControls.GridView.OnBubbleEvent(O bject source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEven t(Object source,
EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)
+115
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String
eventArgument) +163

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+174
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5102


Jun 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Scott Reynolds | last post by:
I am having a problem exposing a class inherited from the collection base class as a webservice. If I expose the collection on a web page all works well and I am very happy. However when I try and...
6
by: John Hoffman | last post by:
Reading registry: .... RegistryKey rksub = rkey.OpenSubKey(s); String valstr = rksub.GetValueNames(); foreach (String vs in valstr) { String vstr = rksub.GetValue(vs).ToString(); OR String...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
1
by: Paul Aspinall | last post by:
Hi Can anyone offer a comparison of System.Convert.ToInt32 vs Int32.Parse Thanks
1
by: loga123 | last post by:
Hi All, I am using Link Button for DELETE on the gridview. When I click on DELETE link, I get the ArgumentOutOfRangeException. But...it deletes the record from table in the database. On...
5
by: Rob Dob | last post by:
I am trying to set the NullValue within the Column properties of my Dataset in VS2005. The DataType is a System.DateTime. and when I try and change it from "(Throw Exception)" I get the following...
4
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I have an RGB color held in a Int32 variable. I using an unsafe code to loop through Bitmap data, and by using the BitmapData.Scan0 pointer I need to copy the Int32 color value into the Bitmap...
0
by: dan | last post by:
Hi, I have a GridView with five columns. One of the column renders its content either as a FileUpload or TextBox - depending on a value in another cell. I created an EditItemTemplate for the...
1
by: AlsonToh | last post by:
No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.