?
Solved

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

Posted on 2012-03-28
6
Medium Priority
?
529 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

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.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 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