Difference

R

rn5a

I have a DataGrid named "dgUsers". The OnDeleteCommand event of the
DataGrid invokes a handler named "DeleteUser". The OnUpdateCommand
event of the DataGrid invokes a handler named "UpdateUser". This is the
code:

Sub DeleteUser(ByVal obj As Object, ByVal ea As
DataGridCommandEventArgs)
Response.Write("Index1: " & ea.Item.ItemIndex & "<br>")
Response.Write("Index2: " & dgUsers.EditItemIndex & "<br>")
dgUsers.EditItemIndex = -1
dgUsers.DataBind()
End Sub

Sub UpdateUser(ByVal obj As Object, ByVal ea As
DataGridCommandEventArgs)
Response.Write("Index1: " & ea.Item.ItemIndex & "<br>")
Response.Write("Index2: " & dgUsers.EditItemIndex & "<br>")
dgUsers.EditItemIndex = -1
dgUsers.DataBind()
End Sub

<asp:DataGrid ID="dgUsers" OnDeleteCommand="DeleteUser"
OnUpdateCommand="UpdateUser" runat="server">
<Columns>
'a few BoundColumns come here
<asp:ButtonColumn ButtonType="LinkButton" CommandName="Delete"
HeaderText="DELETE" Text="DELETE"/>
<asp:EditCommandColumn........./>
</Columns
</asp:DataGrid>

For the Update link, I am using the EditCommandColumn of the DataGrid.

Suppose the user first clicks the Update link of the 3rd row in the
DataGrid (i.e. index=2). Both Index1 & Index2 in the "UpdateUser" sub
are 2. After this, the user clicks the "Delete" link (which is a
ButtonColumn in the DataGrid). Now when the page posts, Index1 & Index2
in the "DeleteUser" sub are 2 & -1 respectively.

Now what's the difference between ea.Item.ItemIndex &
dgUsers.EditItemIndex in the "DeleteUser" sub?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dynamic BoundColumn 2
Controls 3
Controls? 15
DataGrid Edit Problem 9
Controls In DataGrid? 1
OnPreRender 0
DropDownList DataGrid 1
Controls 2

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,204
Latest member
LaverneRua

Latest Threads

Top