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

DataList Hidden Value

Posted on 2015-02-16
Last Modified: 2015-02-17
I am trying to get the hiddenfield value in a datalist. However, this is the result:


        <asp:DataList ID="dataList" RepeatDirection="Horizontal" runat="server">
                <asp:CheckBox ID="dataChkbox" AutoPostBack="true" OnCheckedChanged="dataChkbox_CheckedChanged" runat="server" />
                <asp:HiddenField ID="dataPath" Value='<%#Eval("dataValue")%>' runat="server" />

        protected void dataChkbox_CheckedChanged(object sender, EventArgs e)
            var chk = (CheckBox)sender;
            if (chk.Checked)
                var item = (DataListItem)chk.NamingContainer;
                var dataPathVal = (HiddenField)item.FindControl("dataPath");
		label1.text = dataPathVal.ToString(); 

Open in new window

Question by:RecipeDan
LVL 14

Accepted Solution

Lokesh B R earned 500 total points
ID: 40613607

You have to use the dataPathVal.Value as below.

protected void dataChkbox_CheckedChanged(object sender, EventArgs e)
            var chk = (CheckBox)sender;
            if (chk.Checked)
                var item = (DataListItem)chk.NamingContainer;
                var dataPathVal = (HiddenField)item.FindControl("dataPath");
               label1.text = dataPathVal.Value;

Open in new window


Author Closing Comment

ID: 40613746
Thank you

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Gridview 1 45
VB.NET 2008 - SQL Timeout 9 34
Iteration Help (Asp.net VB) 5 24
Where is this file? 3 25
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

789 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