How to get Key from a repeater?

Posted on 2010-01-11
Medium Priority
Last Modified: 2013-11-26
I created a repeater with 5 cols and Ihave col2 as Hyperlink control. I would like to know how to get the primary key of the row Im clicking so that when it opens the Hperlink page it would capture the ID of that Item from that row. thanks
Question by:zachvaldez
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 58

Expert Comment

ID: 26288380
can you please post some code
LVL 58

Expert Comment

ID: 26288386
LVL 58

Expert Comment

ID: 26288398
Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.


Author Comment

ID: 26294983
The examples were excellent, However what Im trying to achieve is to get the Priamry key of the row and to be more specific..Lets say, I have ProductId, Product name in a repeater control. The Produc name isdisplayed a hyperlink. I would liek toencode that behind scene it reprsents the ProductId. so when clicked , this value is stored in a variable so I can decode it to a target aspx page in the URL string..
LVL 58

Expert Comment

ID: 26295523
what about this: http://dotnetrush.blogspot.com/2006/12/using-repeater-itemcommand.html

you can use CommandArgument on the product name field like this:

CommandArgument='<%#Eval("ProductId") %>'

and on the page:

int PrdID = int.Parse(((LinkButton)e.CommandSource).CommandArgument);

Author Comment

ID: 26296357
Im trying to get the key ID in the Page Load event of the aspx page. Is that possible coz I'd like to pass that to run a store [proc to populate the page . How is that done?
LVL 58

Accepted Solution

HainKurt earned 1000 total points
ID: 26297524
you have to get it on rowCommand event of repeater...

or you can do this... add this line to linkbutton

OnClientClick="selectPrd('<%#Eval("ProductId") %>')"

<input type=hidden id="ProductID">

function selectPrd(prdid){
  document.getElementById("ProductID").value = prd;

and on page_load use

int PrdID = Request["ProductID"]

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 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