从“注释"字段中获取值并将其设置为自定义视觉Webpart中的“标签" [英] Fetching value from Note field and setting it to Label in custom visual webpart
问题描述
我有一个视觉Webpart,其中有一个标签.必须从自定义列表中可用的多行"列(增强的RTF文本)中获取标签文本.标签定义如下:
I have a visual webpart in which I have a label. The label text has to be fetched from a Multiline column (Enhanced Rich text) available in a custom list. The label is defined as below:
<asp:Label ID="lblFName" runat="server" Text=""></asp:Label><em style="color: Red">*</em>
注释"列包含如下数据:
The Note column contains data like :
Do you acknowledge ?
其中,确认"一词表示是超链接.
where, the word "acknowledge" is a hyperlink.
我尝试了以下代码:
public string GetDataforLabel(SPWeb oWeb, string strKey)
{
string strMessage = string.Empty;
try
{
SPList wCustomList = oWeb.Lists["customlist"];
SPQuery listQuery = new SPQuery();
listQuery.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + strKey + "</Value></Eq></Where>";
SPListItemCollection spListItemCol = wConfigList.GetItems(listQuery);
if (spListItemCol != null)
{
strMessage = Convert.ToString(spListItemCol[0]["CustomLabelQue"]);
}
}
catch (Exception)
{
throw;
}
return strMessage;
}
我正确获取了数据,但输出显示为
I am getting the data correctly but the output shows as
Do you acknowledge ?
*
如何在同一行中获取值和astresix(*)?
How to get the value and the astresix (*) in the same line ?
谢谢
推荐答案
您可以尝试对此进行文字控制.
例如:
< : ID 文本 runat : 文学 >
<asp:Literal ID="lt_label" Text="default" runat="server"></asp:Literal>
后端代码:
SPList wCustomList = SPContext.Current.Web.Lists["MyData1"];
var eventDescField = wCustomList.Fields.GetFieldByInternalName("Rich");
var item = wCustomList.GetItemById(2);
var eventDesc = item[eventDescField.Id];
lt_label.Text =string.Format("{0}", eventDesc);
最好的问候,
李
这篇关于从“注释"字段中获取值并将其设置为自定义视觉Webpart中的“标签"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!