Solved

deleting a record

Posted on 2011-09-16
8
233 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 51

Expert Comment

by:HainKurt
ID: 36552404
post code for your template and code for ListView_ItemCommand
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36552413
maybe this way

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

Accepted Solution

by:
HainKurt 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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 51

Expert Comment

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

Author Comment

by:zachvaldez
ID: 36561239
absolutely! thanks
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 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