how can populate,limited word in datalist

Posted by Umeshdwivedi under ASP.NET on 7/10/2011 | Points: 10 | Views : 1027 | Status : [Member] | Replies : 1
Hallo to all
I want to populate limited word in datalist how can i do,
Explain my query
i m populating some data from database
i want to populate only 5 words this posible
pls help me

Latest Technology Trainer
And Part time software consultant


Posted by: Ndebata on: 7/10/2011 [Member] Starter | Points: 25

Hi Umesh,

Could you please clarify a bit about your question?
What I understand is, In a datalist you are showing some contents from database which may have more than five words.
Try to take 5 words while binding the text.
in your aspx page
<asp:Label ID="lblMyCustom" runat="server" Text='<%# GetCustomText(DataBinder.Eval(Container.DataItem, "ActualStringPropertyName")) %>'></asp:Label>

in code behind file , just create a method called GetCustomText which takes an object as parameter and returns a string having five words.
protected string GetCustomText(object actual)

//Write your logic here to get some words
// and return a string.


Umeshdwivedi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response