?
Solved

DataList Hidden Value

Posted on 2015-02-16
2
Medium Priority
?
83 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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