473,425 Members | 1,821 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,425 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 3451
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.