Home > DeveloperSection > Forums > how to get selected LinkButton in ListView
jayprakash sharma
jayprakash sharma

Total Post:117

Posted on    November-20-2014 10:32 PM

 ASP.Net ASP.Net  ListView 

 1 Reply(s)
 898  View(s)
Rate this:

I have a listview which contains a column where I need to put two link buttons - Open and Download to open and download a server file respectively. I have an id column for each row of the list view. I have set the DataKeyNames property of listview to "ID" and verified that DataKeys get populated with the row values. On clicking a particular link button I need the selected ID to determine the link of the server file corresponding to that row. I have added the linkButton_click event but when I try to access SelectedDataKey inside the handler it remains null. How can I get the ID inside the click handler of the link button

Sumit Kesarwani

Total Post:378

Posted on    November-20-2014 11:45 PM

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") %>' />

Don't want to miss updates? Please click the below button!

Follow MindStick