Solved

Repeater ItemCommand Question

Posted on 2007-03-24
6
2,329 Views
Last Modified: 2008-03-17
Hi

I am trying to access several DataItems through the ItemCommand of an Repeater when clicking on a LinkButton e.g

Dim my_id As String
my_id = DataBinder.Eval(e.Item.DataItem, "comp_main_id")

But it gives me always and empty string!

Can anybody help me here?

Thanks, Mike.
0
Comment
Question by:mgasft
  • 3
6 Comments
 
LVL 6

Accepted Solution

by:
sara110 earned 250 total points
ID: 18788256
you know repeater is not very powerful when you want to use button or ... items which you want it to have action, I prefer datalist because it use the primary key as datakey and therefore you could access all of your items and controls in that datalist.
datalist1.DataKeys.Item(e.Item.ItemIndex)
and something like this... ,
http://www.velocityreviews.com/forums/t118666-problem-with-eitemdataitem-in-onitemdatabound.html
0
 
LVL 15

Assisted Solution

by:igor_alpha
igor_alpha earned 250 total points
ID: 18789946
Hi mgasft,

The problem that on ItemCommand even't e.Item.DataItem actually is null. So you can't get value of dataitem.
Walkaround is using of e.Item.Controls property.
For example, if you have lblCompMainID in Repeater you can get value of its Text property:

Dim l1 As Label
l1 = e.Item.Controls .FindControl("lblCompMainID")
'here you have l1.Text
0
 

Author Comment

by:mgasft
ID: 18828862
Hi

It seems that the Repeater has no FindControl?

Mike
0
 
LVL 15

Expert Comment

by:igor_alpha
ID: 18833552
Repeater have FindControl() method.
0
 
LVL 15

Expert Comment

by:igor_alpha
ID: 19165622
My walkaround with label control seems like solution.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

864 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now