Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid DoItemUpdate and DoItemCancel won't work

Status
Not open for further replies.

threeo

Programmer
Mar 31, 2005
49
US
this is driving me cuckoo......

i have a datagrid which has an "edit", "update" and "cancel" set up like this:

<asp:datagrid id=dgNormTypes runat="server" DataSource="<%# DataSet61 %>" AutoGenerateColumns="False" DataKeyField="NORM_TYPE" Width="60%" OnUpdateCommand="DoItemUpdate" OnEditCommand="DoItemEdit" OnCancelCommand="DoItemCancel">
<ItemStyle Font-Size="9pt" Font-Names="Tahoma" ForeColor="#006699" BackColor="#E0E0E0"></ItemStyle>
<HeaderStyle Font-Size="9pt" Font-Names="Tahoma" Font-Bold="True" Wrap="False" ForeColor="White"
BackColor="#006699"></HeaderStyle>
<Columns>
<asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" />
" runat="server">etc.....

then i have the corresponding 3 subroutines "DoItemCancel", "DoItemEdit" and "DoItemUpdate"

for some reason......the DoItemCancel and DoItemUpdate subroutines never execute their code. the DoItemEdit does just fine. i can even just make DoItemUpdate have a single response.write("hello") and it never gets written to the page. i can tell that all three do a postback but no matter what.....the code within DoItemUpdate and DoItemCancel never execute.

here is my doitemedit code (it works fine)

Sub DoItemEdit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
' get a reference to the DataGrid control in this row
Dim oRow As DataListItem = dlOperations.Items(dlOperations.SelectedIndex)
Dim oGrid As DataGrid = CType(oRow.FindControl("dgNormTypes"), DataGrid)

' set the EditItemIndex of the grid to this item's index
oGrid.EditItemIndex = e.Item.ItemIndex
' bind grid to display row in new mode
' get CustomerID from the DataKeys collection of the DataList
oGrid.DataSource = DataSet61
oGrid.DataBind()
End Sub

my doitemupdate and doitemcancel i have currently reduced to a simple response.write("update") and response.write("cancel") - just to see them work but......nothing happens at all.


anyone have any ideas as to why?

threeo
 
yes i see that now.
you may have solved this problem for me.

i went back and looked at the code example i was developing from:


and it is different from mine in that respect.

i am going to try and fix this right now.

thank you so much for taking time to help me with this. i'll let you know if this worked.

threeo
 
well....

almost there...

only now:

Sub DoItemEdit(sender As Object, e As DataGridCommandEventArgs)

' get a reference to the DataGrid control in this row
Dim oGrid As DataGrid = GetDataGridRef()

' set the EditItemIndex of the grid to this item's index
oGrid.EditItemIndex = e.Item.ItemIndex

for some reason....
e.item.itemindex is always 0 - no matter which item i select
 
It could be the same problem: that your datagrid is somehow getting databound right before it gets to DoItemEdit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top