从项目模板获取价值 [英] Get value from a item template

查看:54
本文介绍了从项目模板获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目的是;
我正在尝试在列中的值旁边写一个文本并检索它的值.
例如;该列返回值,例如1,1.所以我希望它看起来像1,1磅.为了实现这一目的,我将数据绑定更改为项目模板,并添加了带有文本"lbs"的标签,因此我完成了第一部分,但我不知道如何从中获取"1.1".

在将数据绑定转换为项目模板之前,我正在使用此代码检索数据绑定的值;

My purpose is;
I am trying to write a text next to a value in a column and retrieve the value of it.
For example; The column returns a value such as 1,1. So I want it to appear like 1,1 lbs. In order to accomplish that I have changed the databound to item template and added a label with a text "lbs" so I accomplish the first part but I dont know how can I get the "1.1" from it.

Before converting the databound to item template I was retriving the value of the databound with this code;

tempPart.RMAPartWeight = Convert.ToDecimal(gvParts.Rows[cnt].Cells[3].Text);



我试图从gridview的"RowDataBound"中获取它,但无法设法获取它.

有什么想法可以从中获取价值吗?



I have tried to get it from gridview''s "RowDataBound" but couldnt manage to get it.

any ideas how can i get the value from it?

推荐答案

您可能会在本文中找到一些帮助. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx [
You may find some help in this article. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx[^]
It explains how to use the DataFormatString in a databound column. I think this is what you would need.
<asp:BoundField DataField="MyField" DataFormatString="{0} lbs" />


然后,您可以像以前一样检索值.


You can then retrieve the value as you did before.


这篇关于从项目模板获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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