检索隐藏字段的值 [英] Retrieve value of Hidden field

查看:66
本文介绍了检索隐藏字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用带有c#的asp.net。我在检索隐藏字段值时出现问题。



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") %>'' />  





所以任何人都告诉我如何在cs文件中获取上面隐藏字段的值或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();







在上面的代码中我得到hd = null代替null它将是显示一些控制价值。

请整理出来。



提前使用。




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.

推荐答案

你好



您确实使用了rounge程序来获取hiddefield的价值和转发器





我以简单的方式为您提供: -



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.


获取cs文件中的值







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);
    }
   
}


您好,



如果你想在你的cs页面中获取它,那么使用Javascript通过查询字符串,Ajax呼叫或通过帖子进行传输。







选择隐藏字段的当前选择值(Sever Control)并在cs页面中访问它,使用逗号分隔多个值。
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.


这篇关于检索隐藏字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆