deleting a record

I d like to delete a row from my listview. I have added/placed the itemtemplate"Remove" with javascript to alert before deleting. I have a stored proc to delete the record passing the Id too.
However I could not get the Id in that row of the record to delete. I place code in listview itemcomnad event. how to get the id using datakeys ?
zachvaldezAsked:
Who is Participating?
 
HainKurtConnect With a Mentor Sr. System AnalystCommented:
VB

Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
Dim ID As String = ListView.DataKeys(dataItem.DisplayIndex).Value.ToString()
DeleteRecord(ID)

add these codes into ListView_OnItemCommand event...
0
 
HainKurtSr. System AnalystCommented:
post code for your template and code for ListView_ItemCommand
0
 
HainKurtSr. System AnalystCommented:
maybe this way

ListViewDataItem dataItem = (ListViewDataItem)e.Item;
string ID = ListView.DataKeys[dataItem.DisplayIndex].Value.ToString();
DeleteRecord(ID);
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
zachvaldezAuthor Commented:
I think I saw this code already and tried to implement it and I was getting error in something like converting string to type integer. Ill have to confirm to you Monday since I don't have VS 2010 on my PC.
0
 
zachvaldezAuthor Commented:
I tried it and I get the error

'Object reference not set to an instance of an object.'
0
 
zachvaldezAuthor Commented:
Ok it worked now. I just need to refesh the page after deleting so it shows the item isnt there. thanks
0
 
HainKurtSr. System AnalystCommented:
call BindData to refresh the data...
0
 
zachvaldezAuthor Commented:
absolutely! thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.