如何获取在数据列表中使用的控件的值 [英] how to get the value of the control which is used inside the datalist

查看:158
本文介绍了如何获取在数据列表中使用的控件的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道如何获取在数据列表中指定的标签框的值.

请回复我.

Hi,

I want to know how to get the value of the label box which is specified inside the datalist.

Please reply to me.

推荐答案

如果您正在使用数据列表中的事件,则

If you are using in the datalist events then

Label Label1 = e.Item.FindControl("Label1") as Label;
string lblValue=Label1.Text;



除了数据列表事件



Other than datalist events

foreach (DataListItem dli in DataList1.Items)
            {
               Label Label1 = e.Item.FindControl("Label1") as Label;
               string lblValue=Label1.Text;
}


使用FindControl方法吗?

试试:
Using FindControl method?

Try:
//VB.NET
Dim lblId As Label = CType(Item.FindControl("lblId"),Label)


// C#
Label lblId = new Label();
lblId = (Item.FindControl("lblId")) as Label;


当我使用此标签时,出现应用程序文件中的错误,如预期的标识符
when i used this i get the error in application file like identifier expected


这篇关于如何获取在数据列表中使用的控件的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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