[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2012-03-28
6
Medium Priority
?
534 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 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 quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
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

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month19 days, 12 hours left to enroll

872 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