Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
Hi everyone,
I am using asp.net with c#. I m getting problem in retrieve hidden field value.
 
<input type="hidden" id="hdn_perchher_id_<%# Container.ItemIndex %>" value='<%# Eval("user_id") %>' />  
 
So anyone tell me how to get value or id of above hidden field in cs file.
 
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater Repeater2 = (Repeater)e.Item.FindControl("rpt_Common_Perchher");
                HiddenField hd = (HiddenField)e.Item.FindControl("hdn_perchher_id_<%# Container.ItemIndex %>");
 
                cls_PerchhConnection perchhconnection = new cls_PerchhConnection();
                DataTable dt_common_perchhers = new DataTable();
                int user_id1 = Convert.ToInt32(Session["perchh_uid"]);
                
                dt_common_perchhers = perchhconnection.Proc_GetCommonPerchhers(user_id1, 57);
 
                Repeater2.DataSource = dt_common_perchhers;
                Repeater2.DataBind();           
 

In above code i got hd = null in place of null it will be show some value of control.
Please sort it out.
 
Thanx in Advance.
Posted 9-Jan-13 22:14pm
Edited 9-Jan-13 22:45pm
v3
Comments
Suvabrata Roy at 10-Jan-13 4:17am
   
What kind of problem...?
faisal23 at 10-Jan-13 4:18am
   
I want to get value of this hidden field which is dynamic and bind in repeater..
Suvabrata Roy at 10-Jan-13 4:22am
   
R you trying to get the value from code behind or in javascript?
faisal23 at 10-Jan-13 4:25am
   
in cs file i have to use its value as a parameter for other function.
If i got the idea how to get id of this control i able find its value.
sarathsprakash at 10-Jan-13 4:25am
   
do you want to retrieve the value in the next form after submitting
faisal23 at 10-Jan-13 4:29am
   
No it is on same form. I have 2 repeaters in parent repeater this hidden field retrieved dynamically in nested repeater i want the value of this hidden field.
So i want how to retrieve id or value of this control for passing parameter to one of the function.
faisal23 at 10-Jan-13 4:35am
   
You are giving me solution but its not working for me you dont see my problem it is binded dynamically and its id "hdn_perchher_id_<%# Container.ItemIndex %>" so how i can do this. IT
sarathsprakash at 10-Jan-13 4:38am
   
just go through the below solution and reply
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hello
 
You did use rounge procedure for getting value of hiddefield with in repeater
 

in simple way I provide you :-
 
<input type="hidden" id="Rizwan" value='<%# Eval("user_id") %>' />  
AND YOUR CODE BEHIND :-
 
HiddenField hd = (HiddenField)e.Item.FindControl("Rizwan");
 

I hope your Problem will resolve if not Please give me your Comment.
  Permalink  
Comments
faisal23 at 10-Jan-13 5:27am
   
Hi I update my code according to you but i got error. Hidden variable is null.
"System.NullReferenceException: Object reference not set to an instance of an object"
rizwan muhammed khan gouri at 10-Jan-13 5:50am
   
can you give me your code
rizwan muhammed khan gouri at 10-Jan-13 5:50am
   
runat="server" also used
manoj kumar choubey at 11-Jan-13 2:07am
   
Very Nice Rizwan muhammed khan gouri
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

For getting the the value in the cs file
 

 
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String a = HiddenField1.Value;
        Response.Write(a);
    }
   
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
If you want to get it in your cs page then transfer using Javascript through Query string, Ajax Call call or via post.
 
Or
 
Select the current selection value to a hidden field (Sever Control) and access it in your cs page, for multiple value separate using comma.
  Permalink  
Comments
faisal23 at 10-Jan-13 4:55am
   
It is not server control.
Suvabrata Roy at 10-Jan-13 4:58am
   
Yes, I know insert another hidden field (Server Control) and on selection of your row you will set the value to that server hidden filed via Javascript and now get it back on server.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

<asp:hiddenfield id="hdnEmailID" runat="server" xmlns:asp="#unknown" />
 

<pre lang="cs">protected void LinkGroupSummary_Click(object sender, EventArgs e)
        {
            hdnEmailID.Value = this.EmailList;
            Server.Transfer("Default2.aspx");
 
        }
 

 

if (Page.PreviousPage != null)
                    {
                        HiddenField MyHiddenValue = (HiddenField)Page.PreviousPage.FindControl("hdnEmailID");
                        if (MyHiddenValue != null)
                        {
                            string email = MyHiddenValue.Value;
                        }
                    }
  Permalink  
Comments
faisal23 at 10-Jan-13 4:56am
   
First of all it is not server control and second is that it is dynamic bind in repeater means contains many values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 225
1 OriginalGriff 140
2 Sergey Alexandrovich Kryukov 137
3 _Amy 115
4 manoj kumar choubey 115
0 OriginalGriff 7,320
1 Sergey Alexandrovich Kryukov 6,043
2 Maciej Los 3,749
3 Peter Leow 3,408
4 DamithSL 2,555


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100