Solved

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

Posted on 2012-03-28
6
519 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
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 37778541
0
 
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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Initial get page response times and IIS8 15 52
Service Controller 1 24
Add different cell to otherwise similiar row 4 40
Send SMS from VB via Sierra Wireless Modem 2 22
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

825 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