Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > "Object variable or With block variable not set" error in Edit event

Reply
Thread Tools

"Object variable or With block variable not set" error in Edit event

 
 
Kiyomi
Guest
Posts: n/a
 
      08-11-2006
Hello,



I have a datagrid (dgStaffList) with 1 bound column, 2 template columns and
1 Edit column and 1 Delete column. Each template column contains a dropdown
list.



Then I have the following codes, where e.Item.Cells(4) is Delete column :





Sub dgStaffList_ItemCreated(ByVal Sender As Object, ByVal e As
DataGridItemEventArgs)



Select Case e.Item.ItemType

Case ListItemType.Item, ListItemType.AlternatingItem ' ,
ListItemType.EditItem

Dim myTableCell As TableCell

myTableCell = e.Item.Cells(4)

Dim myDeleteButton As LinkButton

myDeleteButton = myTableCell.Controls(0)



myDeleteButton.Attributes.Add("onclick", _

"return confirm('Are you sure you want to delete " +
e.Item.DataItem(1) + "?');")





End Select



End Sub



"Delete" works very well, with confirmation messagebox popping up "Are you
sure you want to delete [staff member's name]."



When I click "Edit", however, I get the error message "Object variable or
With block variable not set" in the line :



myDeleteButton.Attributes.Add("onclick", _

"return confirm('Are you sure you want to delete " +
e.Item.DataItem(1) + "?');")



I tried to replace it with the following line :



myDeleteButton.Attributes.Add("onclick", _

"return confirm('Are you sure you want to delete
this staff member ?');")



Then both "Delete" and "Edit" work, but the staff member's name cannot be
displayed in the messagebox before deleting.



It seems that e.Item.DataItem(1) cannot be recognized in the "Edit" event.
How can I solve this problem ?



I would appreciate very much your advice.



Kiyomi


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM
Object variable or With Block variable not set error =?Utf-8?B?TmV3YmllRGV2?= ASP .Net 0 04-26-2006 03:11 AM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM



Advertisments