• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

How to get Key from a repeater?

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
0
zachvaldez
Asked:
zachvaldez
  • 5
  • 2
1 Solution
 
HainKurtSr. System AnalystCommented:
can you please post some code
0
 
HainKurtSr. System AnalystCommented:
0
 
HainKurtSr. System AnalystCommented:
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
zachvaldezAuthor Commented:
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..
0
 
HainKurtSr. System AnalystCommented:
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);
0
 
zachvaldezAuthor Commented:
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?
0
 
HainKurtSr. System AnalystCommented:
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">

<script>
function selectPrd(prdid){
  document.getElementById("ProductID").value = prd;
}
</script>

and on page_load use

int PrdID = Request["ProductID"]
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now