Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Binding Note field on GetDataTable showing unwanted div tag

$
0
0

Hi,

I have a Note field called "Description". I am trying to bind a asp.net listbox with the values of the Note field.

I have written the code as below:

SPList testList = oWeb.Lists["ListName"];
SPListItemCollection testListItems = testList.Items;
DataTable dtTestGroup = new DataTable();
if testListItems.Count > 0)
{
   dtTestGroup = testListItems.GetDataTable();
   lstDesc.DataTextField = "Description";
   lstDesc.DataValueField = "Description";
   lstDesc.DataSource = dtTestGroup;
   lstDesc.DataBind();
}

In the UI, now i am seeing the unwanted div tags at the front of the text.

For a normal list item, I can do a regex as below to remove the div entries

Regex.Replace(currentItem["Your Field Name"].ToString(), "<.*?>", string.Empty);

But, when using the "Datatextfield" and "datavaluefield", how to use the regex in the above condition? How to show only the text?

Thanks



Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>