Solved

deleting a record

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

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

939 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now