![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a delete button on my page which deletes the selected row in a gridview. After the deletion the selected index gets reset to -1. How can I keep the same selected index? Nirmal |
#3
| |||
| |||
|
|
If the index of the deleted row is greater than the selectedindex, you could take it into a local variable before deleting (perhaps in OnRowDeleting event), and after delete operation (in OnRowDeleted event), set it back. If the index of the deleted row is less than or equal to selected index, you'd need to decrement one from the index (since it's not correct anymore as it vontains the deleted row)-->could lead to index being out of range -- Teemu Keiski AspInsider, ASP.NET MVP http://blogs.aspadvice.com/joteke http://teemukeiski.net "Nirmal Singh" <nirmal.singh (AT) notthisbittowerhamlets (DOT) gov.uk> wrote in message news:OYUlj9GKIHA.1204 (AT) TK2MSFTNGP03 (DOT) phx.gbl... I have a delete button on my page which deletes the selected row in a gridview. After the deletion the selected index gets reset to -1. How can I keep the same selected index? Nirmal |
#4
| |||
| |||
|
|
Teemu I've added the following code in the OnRowDeleting event DeletedRow = e.RowIndex In the OnRowDeleted event I have the following code RowCount = RowCount - 1 If DeletedRow = RowCount Then grdCurrentAbsence.SelectedIndex = DeletedRow - 1 Else grdCurrentAbsence.SelectedIndex = DeletedRow End If RowCount is a local varaiable holding the number of rows in the gridview. This is still resetting the selectedIndex to -1. What am I doing wrong? Nirmal Singh "Teemu Keiski" <joteke (AT) aspalliance (DOT) com> wrote in message news:eNBonzbKIHA.4688 (AT) TK2MSFTNGP06 (DOT) phx.gbl... If the index of the deleted row is greater than the selectedindex, you could take it into a local variable before deleting (perhaps in OnRowDeleting event), and after delete operation (in OnRowDeleted event), set it back. If the index of the deleted row is less than or equal to selected index, you'd need to decrement one from the index (since it's not correct anymore as it vontains the deleted row)-->could lead to index being out of range -- Teemu Keiski AspInsider, ASP.NET MVP http://blogs.aspadvice.com/joteke http://teemukeiski.net "Nirmal Singh" <nirmal.singh (AT) notthisbittowerhamlets (DOT) gov.uk> wrote in message news:OYUlj9GKIHA.1204 (AT) TK2MSFTNGP03 (DOT) phx.gbl... I have a delete button on my page which deletes the selected row in a gridview. After the deletion the selected index gets reset to -1. How can I keep the same selected index? Nirmal |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |