473,520 Members | 2,874 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting row from GridView causes ArgumentOutOfRangeException during System.Web.UI.WebControls.Grid*View.set_SelectedIn dex(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.Ra*isePostBackEvent(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 29 '06 #1
1 2300
"loga123" <vd**********@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.

Jul 4 '06 #2

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

Similar topics

2
3455
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 Gridview_rowdatabound, I am dynamically building hyperlink control based on the values in the other fields. Here is my code for Gridview_rowdatabound. It...
0
1793
by: Kondapanaidu | last post by:
Hi, I am using Visual Studio 2005 ASP.NET Using C#. My form has one. Grid view This it self having Text box and Dropdowns. I Have coule of questions like?
12
4688
by: brwalias | last post by:
Hi, using .net 2 sql server 2005 Here is my situation: I'm passing a variable in the url from a selection on Page A and need to display the results on the Results page be based on that variable in the url. I would like that variable to trigger a stored and
1
2604
by: =?Utf-8?B?TG95b2xhIHN0YWxpbg==?= | last post by:
Hi, I am using ASP.Net 2.0 version and Windows'XP OS. I am useing the Grid view control to display the user details along with the paging concept provided by the grid view control. When i click the paging link (2,3,4.. ) it produces the result properly, But my problem is when i tried to press the Refresh button in the explorer, it throws...
0
1258
by: hellboss | last post by:
Hi ! Im using Asp.net vs05, rite now iam working with a grid view where i map the column values from a database to the Button Field's DataTextfield, example "Empno" , The problem is that ! after i map the DataTextField value, i want the value in the button field to be displayed in a msg box when the corresponding Button is clicked . Kindly...
1
4565
by: vibhashin | last post by:
I hve extracted a coloumn in combo box from database. I want that when i select a particular value from the combo box it should display the related details of the selected value in the combo box in the data grid view from the database.
1
1642
by: eranby | last post by:
hi, I'm using access db in my c# program I have a select query and I want to present the result in data grid view ,I succeed doing that with this while loop int i = 0,j=0; while (dbReader.Read()) { dataGridView2.Rows.Add(); dataGridView2.Value = (string) .Value = (string)dbReader.GetValue(1); j++; ...
2
4138
by: eranby | last post by:
hi, I'm using access db in my c# program I have a select query and I want to present the result in data grid view ,I succeed doing that with this while loop Code: ( c ) int i = 0,j=0; while (dbReader.Read()) { dataGridView2.Rows.Add();
1
1908
by: John | last post by:
Hi I have a grid view bound to an SqlDataSource. One of the fields in grid view is a hyperlink field. How can I set the hyperlink field's navigationurl to the value of a field coming form the underlying SqlDataSource? Thanks Regards
0
7326
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7471
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5771
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4810
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3308
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3298
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
533
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.