473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem with Datalist data

I'm displaying the data through a DataList. In which i've a field, Job
Description which shows all the data from "JobDescription" column in
the database.

<%# DataBinder.Eval(Container.DataItem, "JobDescription")%>

But Initially i just want only some part of the some particular amount
data to be displayed (say 100 words or some 2000 characters) not the
whole data.Is there any way to trim this function to above requirement
using strings or do I need to do some manupulation in the database?
How can I do this?
Thanks in Advance

Nov 19 '05 #1
5 958
You can process data in datalist_ItemdataBound event.

http://msdn.microsoft.com/library/de...boundtopic.asp

HTH

Elton Wang

"savvy" wrote:
I'm displaying the data through a DataList. In which i've a field, Job
Description which shows all the data from "JobDescription" column in
the database.

<%# DataBinder.Eval(Container.DataItem, "JobDescription")%>

But Initially i just want only some part of the some particular amount
data to be displayed (say 100 words or some 2000 characters) not the
whole data.Is there any way to trim this function to above requirement
using strings or do I need to do some manupulation in the database?
How can I do this?
Thanks in Advance

Nov 19 '05 #2
You can handle either DataItemBound or PreRender event. In the event you
have access to the data that will be rendered. You can do with the data
whatever you want: trim, format, change style etc.

Eliyahu

"savvy" <jo******@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
I'm displaying the data through a DataList. In which i've a field, Job
Description which shows all the data from "JobDescription" column in
the database.

<%# DataBinder.Eval(Container.DataItem, "JobDescription")%>

But Initially i just want only some part of the some particular amount
data to be displayed (say 100 words or some 2000 characters) not the
whole data.Is there any way to trim this function to above requirement
using strings or do I need to do some manupulation in the database?
How can I do this?
Thanks in Advance

Nov 19 '05 #3
Thanks for your replies
It helped me alot
I'm still a little bit confused , if u can give me any sort of sample
code for the above problem it will be great help to me
Thanks Once Again in Advance

Nov 19 '05 #4
Another method is to write a function and call it during the databinding..
code will be like below

<%# TrimText(DataBinder.Eval(Container.DataItem, "JobDescription")) %>

This code behind function would look like

protected bool TrimText(string val)
{
string TrimmedVal = // add your logic to trim val here
return(TrimmedVal);
}


"savvy" wrote:
I'm displaying the data through a DataList. In which i've a field, Job
Description which shows all the data from "JobDescription" column in
the database.

<%# DataBinder.Eval(Container.DataItem, "JobDescription")%>

But Initially i just want only some part of the some particular amount
data to be displayed (say 100 words or some 2000 characters) not the
whole data.Is there any way to trim this function to above requirement
using strings or do I need to do some manupulation in the database?
How can I do this?
Thanks in Advance

Nov 19 '05 #5
Thanks for all your help
I used the above idea and implemented the following function as given
below. And its working perfectly

string Truncate(string input, int characterLimit) {

string output = input;

// Check if the string is longer than the allowed amount
// otherwise do nothing

if (output.Length > characterLimit && characterLimit > 0) {
// cut the string down to the maximum number of characters
output = output.Substring(0,characterLimit);

// Check if the character right after the truncate point was a
space

// if not, we are in the middle of a word and need to remove the
rest of it
if (input.Substring(output.Length,1) != " ") {
int LastSpace = output.LastIndexOf(" ");

// if we found a space then, cut back to that space
if (LastSpace != -1) {
output = output.Substring(0,LastSpace);
}
}
// Finally, add the "..."
output += "...";
}
return output;
}
Thanks to everyone

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kscdavefl | last post by:
I am trying to fill a datalist with table names from an Oracle database. The program works fine using the following code: private void GetTables() { // open a database connection string con...
1
by: Glenn Owens | last post by:
Here's the scenario: I have a DataList populated from a datatable sitting inside a fieldset. Each element (row) in the Datalist has the following child controls: asp:checkbox, asp:image,...
2
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
0
by: s.gregory | last post by:
My page layout is like this: Page >DataList (databound using ObjectDataSource1 contained in page) >>Items >>>UserControl >>>>GridView (databound using another ObjectDataSource2 contained in...
0
by: Maran | last post by:
We have come across a situation that I thinks not many have. Grateful for all responses. Regards Maran ************* * Scenario A DataList binds to a DataRow, with "RegionName" och...
2
by: scottls | last post by:
Hi All, Thanks for reading my post. I have been working on getting nested datalists working properly wihtin my framework for many days and I think I'm almost there. See if you could help me...
1
by: David | last post by:
Hi, This one appears a little strange to me. Here is the scenario. I load a datalist the first time a page is run. The page has a !IsPostback and the datalist gets loaded at this point. I...
5
by: Aussie Rules | last post by:
Hi, I am still having a problem using a datalist control using VB.net This is my code...... In the HTML page I have <asp:DataList ID="DataList1" runat="server">
0
by: Bieniu | last post by:
I have DataList control on my own contro land it is bind to SqlDataSource control. My problem is that DataList is getting needed data twice what is for me very strange. I have some code in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.