473,387 Members | 1,548 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,387 software developers and data experts.

Difficulty when deleting row from a gridview

103 100+
Hi all,

when i try to delete the last row from gridview, i got an exception "Array index out of bound..

When i try to delete some other row, all the rows that follow that row is deleted..

For example,

If i have 10 rows in a grid view and when i try to delete the 10th row, it throws an exception..

When i try to delete 8th row, the rows 8,9,10 is deleted..

Please help me to solve this problem..

Regards,

Mathew.
Sep 28 '07 #1
2 1542
cie
6
Anyway I have no idea what language you are using but if it is C# i hope it can help you.

assumed that the grid view name is dataGridView

use this line of coding:
dataGridView.Rows.Remove(dataGridView.Rows[dataGridView.RowCount - 1]);

because the row's index is zero based so to get last row index is the number of rows - 1

Hi all,

when i try to delete the last row from gridview, i got an exception "Array index out of bound..

When i try to delete some other row, all the rows that follow that row is deleted..

For example,

If i have 10 rows in a grid view and when i try to delete the 10th row, it throws an exception..

When i try to delete 8th row, the rows 8,9,10 is deleted..

Please help me to solve this problem..

Regards,

Mathew.
Sep 29 '07 #2
send me the coding u used to delete the record in gridview.. so that il try to help u..

Cheers
Sep 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: loga123 | last post by:
I am using a gridview with ASP 2.0 and VB.Net 2005. I would like to be able to pop-up a javascript alert('Are you sure') confirmation when the user clicks the 'Delete link' without adding an...
2
by: Narshe | last post by:
I have a gridview with datakeyname="Id" that is using a sqldatasource. When I click delete on the gridview, the datakeys property is empty during the deleting event.
0
by: gr8beer | last post by:
The gridview rebinds data before the RowCommand or RowEditing events fire. So, if a new record is added to the underlying datasource that changes the index of the row you are trying to edit, you...
2
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the...
1
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the...
11
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the...
1
by: David C | last post by:
I want to use the deleting event on a gridview (using link button) to get the ID of the row being deleted so I can make sure that ID is not in another table. How do I reference this in my VB code...
1
by: Vajrala Narendra | last post by:
Hi, all am working on asp.net, c# 2.0 i want to delete a row from a grid view for that i take datakeyname inn gris view i wrote coding as 1. <asp:GridView ID="GridView2" runat="server"...
4
by: Queen Soso | last post by:
hi all, I have this error when I click delete link in the gridview: 'unable to cast object of type 'ASP.WebForm1_aspx' to type "system.Web.UI.WebControls.GridviewRow' I really need help as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
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,...

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.