Solved

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

Posted on 2012-03-28
6
511 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

12 Experts available now in Live!

Get 1:1 Help Now