Difference
- From: rn5a@xxxxxxxxxxxxxx
- Date: 29 Nov 2006 18:09:29 -0800
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?
.
- Follow-Ups:
- Re: Difference
- From: Kevin Frey
- Re: Difference
- Prev by Date: Changing User
- Next by Date: RE: Changing User
- Previous by thread: Changing User
- Next by thread: Re: Difference
- Index(es):