获取详细信息查看templatefield值... [英] Get DetailsView templatefield value...

查看:76
本文介绍了获取详细信息查看templatefield值...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试从detailsview字段内的标签中获取文本.该字段实际上是一个模板字段,并且在其ItemTemplate中有一个Label控件(ID ="Label8"),我想读取该Text属性.

我尝试了以下操作,但未成功(返回c = null ):

Hi all,

i am trying to get the text from a label that it is inside of a detailsview field. This field is in fact a template field, and inside its ItemTemplate there is the Label control (ID = "Label8") which Text property i want to read.

i tried the following without success (returns c = null):

System.Web.UI.Control c = dvCU.FindControl("Label8");<br />                string s = ((System.Web.UI.WebControls.Label)c).Text;<br />


有人可以帮助我吗?

先谢谢了.


can anyone help me?

Thanks in advance.

于2009年4月7日星期二下午4:27修改
modified on Tuesday, April 7, 2009 4:27 PM

推荐答案

代码.换句话说,您的代码是哪种方法.

您无法以所显示的方式获得控件.

1.您需要访问详细信息视图控件
2.那么您需要访问控件
3中的特定行.那么您需要进行查找

protected void grdItemDetail_RowDataBound(object sender, GridViewRowEventArgs e)<br />{<br /> Image img = (Image)e.Row.FindControl("Thumbnail");<br />}

where is your code. In other words, which method is your code in.

you can not get the controls the way you are showing.

1. you need to access your details view control
2. then you need to access specific row in the control
3. then you need to do a find

protected void grdItemDetail_RowDataBound(object sender, GridViewRowEventArgs e)<br />{<br /> Image img = (Image)e.Row.FindControl("Thumbnail");<br />}


这篇关于获取详细信息查看templatefield值...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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