---
title: "how to get selected LinkButton in ListView"  
description: "how to get selected LinkButton in ListView"  
author: "Anonymous User"  
published: 2014-11-20  
updated: 2014-11-20  
canonical: https://www.mindstick.com/forum/12661/how-to-get-selected-linkbutton-in-listview  
category: "asp.net"  
tags: ["asp.net", "listview"]  
reading_time: 1 minute  

---

# how to get selected LinkButton in ListView

I have a [listview](https://www.mindstick.com/articles/12744/listview-in-android) which contains a column where I need to put two link buttons - Open and [Download](https://www.mindstick.com/articles/188403/website-to-download-photos-from-instagram) to open and download a [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) file respectively. I have an [id column](https://www.mindstick.com/forum/34651/how-can-reset-identity-seeding-in-sql-on-id-column) for each row of the list view. I have set the DataKeyNames [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) of listview to "ID" and verified that DataKeys get populated with the row values. On clicking a particular link [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) I need the selected ID to determine the link of the server file corresponding to that row. I have added the linkButton_click [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) but when I try to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) SelectedDataKey inside the [handler](https://www.mindstick.com/forum/33532/handler-pagehandlerfactory-integrated-has-a-bad-module-managedpipelinehandler-in-its-module-list) it remains null. How can I get the ID inside the click handler of the link button

## Replies

### Reply by Sumit Kesarwani

you can use this:

```
 protected void ConferencesListView_ItemCommand(object sender, ListViewCommandEventArgs e)    {        int _Id;       
int.TryParse(e.CommandArgument.ToString(), out _Id);        if(e.CommandName == "View")        {        }    }
```

and in designer:

<asp:LinkButton ID="ViewLinkButton" runat="server" CommandName="View" CommandArgument='<%# Eval("ID") %>' />


---

Original Source: https://www.mindstick.com/forum/12661/how-to-get-selected-linkbutton-in-listview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
