Solved

deleting a record

Posted on 2011-09-16
8
235 Views
Last Modified: 2012-05-12
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 ?
0
Comment
Question by:zachvaldez
  • 4
  • 4
8 Comments
 
LVL 52

Expert Comment

by:Huseyin KAHRAMAN
ID: 36552404
post code for your template and code for ListView_ItemCommand
0
 
LVL 52

Expert Comment

by:Huseyin KAHRAMAN
ID: 36552413
maybe this way

ListViewDataItem dataItem = (ListViewDataItem)e.Item;
string ID = ListView.DataKeys[dataItem.DisplayIndex].Value.ToString();
DeleteRecord(ID);
0
 
LVL 52

Accepted Solution

by:
Huseyin KAHRAMAN earned 250 total points
ID: 36552418
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:zachvaldez
ID: 36553872
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
 

Author Comment

by:zachvaldez
ID: 36560535
I tried it and I get the error

'Object reference not set to an instance of an object.'
0
 

Author Comment

by:zachvaldez
ID: 36560890
Ok it worked now. I just need to refesh the page after deleting so it shows the item isnt there. thanks
0
 
LVL 52

Expert Comment

by:Huseyin KAHRAMAN
ID: 36560971
call BindData to refresh the data...
0
 

Author Comment

by:zachvaldez
ID: 36561239
absolutely! thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question