检索asp.net中的值 [英] Retrieving the value in asp.net

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

问题描述

我已经在数据库中创建了一个表作为Register,并且由一个单行的RegisterId组成,该行的数据类型为int.

在aspx
我创建了一个gridview并将数据源连接到上表.可用字段将转换为模板"字段.这是一个隐藏字段的边界.

I''ve created a table in the database as Register and consists of a single row RegisterId which is of datatype int.

in aspx
i''ve created a gridview and connected the datasource to the above table. The field available is converted to the Template field. This is bounded to an hidden field.

how can i retrieve the value from that hidden field in coding for the particular gridview row?

推荐答案

<asp:TemplateField headertext="Product Name">
        <ItemTemplate>
            <asp:HiddenField ID="hdRegisterID" runat="server"  Value='<%#Eval("RegisterID")%>'/>
        </ItemTemplate>
    </asp:TemplateField>




在代码中,您可以执行以下操作




In the code, you could do something like this

foreach (GridViewRow row in gvProducts.Rows)
{
   string registerID = ((HiddenField)row.FindControl("hdRegisterID")).Value;
}


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

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