Solved

DataList Hidden Value

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

System.Web.UI.WebControls.HiddenField

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

        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

0
Comment
Question by:RecipeDan
[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
2 Comments
 
LVL 15

Accepted Solution

by:
Lokesh B R earned 500 total points
ID: 40613607
Hi,

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


https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hiddenfield.value(v=vs.110).aspx
0
 
LVL 1

Author Closing Comment

by:RecipeDan
ID: 40613746
Thank you
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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