Click here to Skip to main content
15,879,047 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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
Updated 9-Jan-13 22:45pm
v3
Comments
Suvabrata Roy 10-Jan-13 4:17am    
What kind of problem...?
faisal23 10-Jan-13 4:18am    
I want to get value of this hidden field which is dynamic and bind in repeater..
Suvabrata Roy 10-Jan-13 4:22am    
R you trying to get the value from code behind or in javascript?
faisal23 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 10-Jan-13 4:25am    
do you want to retrieve the value in the next form after submitting

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 :-

XML
HiddenField hd = (HiddenField)e.Item.FindControl("Rizwan");



I hope your Problem will resolve if not Please give me your Comment.
 
Share this answer
 
Comments
faisal23 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 10-Jan-13 5:50am    
can you give me your code
rizwan muhammed khan gouri 10-Jan-13 5:50am    
runat="server" also used
Manoj Kumar Choubey 11-Jan-13 2:07am    
Very Nice Rizwan muhammed khan gouri
For getting the the value in the cs file



C#
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String a = HiddenField1.Value;
        Response.Write(a);
    }
   
}
 
Share this answer
 
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.
 
Share this answer
 
Comments
faisal23 10-Jan-13 4:55am    
It is not server control.
Suvabrata Roy 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.
C#
<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");

        }





C#
if (Page.PreviousPage != null)
                    {
                        HiddenField MyHiddenValue = (HiddenField)Page.PreviousPage.FindControl("hdnEmailID");
                        if (MyHiddenValue != null)
                        {
                            string email = MyHiddenValue.Value;
                        }
                    }
 
Share this answer
 
Comments
faisal23 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900