Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Deleting row from GridView causes ArgumentOutOfRangeException during System.Web.UI.WebControls.Grid­View.set_SelectedIndex(Int32 value)

2 views
Skip to first unread message

loga123

unread,
Jun 29, 2006, 12:58:26 PM6/29/06
to
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_SelectedIndex(Int32 value)
+1454311
System.Web.UI.WebControls.GridView.HandleDeleteCallback(Int32
affectedRows, Exception ex) +354
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary
oldValues, DataSourceViewOperationCallback callback) +123
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row,
Int32 rowIndex) +927
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +1155
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source,
EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
+115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +163


System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.Ra­isePostBackEvent(String

eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+174
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5102

Jan Hyde

unread,
Jul 4, 2006, 9:04:04 AM7/4/06
to
"loga123" <vdevar...@covansys.com>'s wild thoughts were
released on 29 Jun 2006 09:58:26 -0700 bearing the following
fruit:

>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
>

Is that your real code?

Because you declare 'iQSeq' but us 'iQ'


Jan Hyde (VB MVP)

--
Why don't boxers have sex before a fight?

Because they don't fancy each other.

0 new messages