Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.NET - C# - Repeater - Get Value on Click Event

Posted on 2012-03-28
6
Medium Priority
?
532 Views
Last Modified: 2012-04-12
I have a repeater as shown below.  How do I get the value of the hidden field when clicking on it?

 <asp:Repeater ID="rptFiles" runat="server"
        onitemcommand="rptFiles_ItemCommand" >
    <HeaderTemplate>
        <strong>File Name</strong><br />
    </HeaderTemplate>
    <ItemTemplate>
        <asp:LinkButton ID="lbDisplayName" runat="server"
               Text="<%# ((Files)Container.DataItem).DisplayName %>" />
        <asp:HiddenField Id="hdValue" runat="server"
               value="<%# ((Files)Container.DataItem).FileName %>" /><br />
    </ItemTemplate>
    <FooterTemplate>
    </FooterTemplate>
</asp:Repeater>
0
Comment
Question by:CipherIS
[X]
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
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37778566
var hiddenField=e.item.findcontrol("HiddenFieildId") as HiddenField;
var valuev= hiddenField.value;

Open in new window

0
 
LVL 1

Author Comment

by:CipherIS
ID: 37778783
valuev = "".  

It is not returning the value.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37778826
this means no value is bounded to it, try checking in databound event handler....
0
 
LVL 1

Author Comment

by:CipherIS
ID: 37778888
please explain the "databound event handler"?  How do I check that?

Here is the code that is getting the data
 
protected void Page_Load(object sender, EventArgs e)
{
        //Get Files
        rptFiles.DataSource = FileList.getFiles;
        rptFiles.DataBind();
}

//FILES
public class FileList
{
     static FileList()
     {
            ITransferService _getFiles = new TransferServiceClient();

            getFiles = new List<Files>();
            foreach (var files in _getFiles.APICustomerFiles("1234", false))
            {
                getFiles.Add(new Files() { DisplayName = files.DisplayName });
                getFiles.Add(new Files() { FileName = files.FileName });
            }
        }
        public static List<Files> getFiles { get; set; }
    }
}

public class Files
{
    public string DisplayName { get; set; }
    public string FileName { get; set; }
}
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 2000 total points
ID: 37778927
change the code as given below:-
public class FileList
{
     static FileList()
     {
            ITransferService _getFiles = new TransferServiceClient();

            getFiles = new List<Files>();
            foreach (var files in _getFiles.APICustomerFiles("1234", false))
            {
                getFiles.Add(new Files() { DisplayName = files.DisplayName, FileName = files.FileName  });
            }
        }
        public static List<Files> getFiles { get; set; }
    }
}

Open in new window

0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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