This is a migrated thread and some comments may be shown as answers.

Accessing datasource from ItemCommand

2 Answers 171 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 14 Nov 2011, 06:59 PM
Seems like this should be simple, but I'm not seeing it.
I have a RadListView displaying data from a table and I have LinkButtons on each item to delete them. Everything fires like I would expect but I'm having trouble in my ItemCommand event.

In my ItemCommand event I just need to be able to access my "pri_key" column of the bound table.
I'm used to doing something like e.Item.DataItem("pri_key") in other bound controls but I don't see anything like that.
How should I be accessing this? Thanks!

Thanks!

2 Answers, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 14 Nov 2011, 07:08 PM
Well, I think I have it figured out by passing the key in the CommandArgument. I had tried this before, but putting quotes around the <%# %> tags was throwing an error. Omitting the quotes fixed it (which seems weird to be but whatever works!).

If this is a bad approach please let me know, otherwise I think I'm ok on this!

0
Accepted
Sebastian
Telerik team
answered on 15 Nov 2011, 12:15 PM
Hello Matt,

Your approach seems fine to me. Feel free to utilize it if appropriate.

Best regards,
Sebastian
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ListView
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or