limit or customize the data displayed using repeaters contol.

I

Imran Aziz

Hello All,
I use a repeater control to display data, here is line I use to output
data

<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

now the issue is that this is a description field and I only want to display
the first twenty words of the description, how can I do that ? can I alter
the above command to do that, or do I need to do that in SQL ?



Imran.
 
B

Brock Allen

Change:
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

To:

<%# Get20WordDescription(((DataRowView)Container.DataItem)["sItemDesc"])%>

and add a method in your page:

protected string Get20WordDescription(string val)
{
string[] parts = val.Split(' ');
if (parts.Length > 20)
{
string[] subParts = new string[20];
parts.CopyTo(subParts);
return String.Concat(subParts);
}
return val;
}

My Get20WordDescription is very much a hack, so if you spend some time I'm
sure you can come up with something much better.




Hello All,
I use a repeater control to display data, here is line I use to
output
data
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

now the issue is that this is a description field and I only want to
display the first twenty words of the description, how can I do that ?
can I alter the above command to do that, or do I need to do that in
SQL ?

Imran.
 
I

Imran Aziz

Thank you so very much Brock for coming back to me again :)
I tried this one out, and get this error for some strange reason, any tips
as to why this is happening and how to sort it out?

Error 2 The best overloaded method match for
'showitems.Get20WordDescription(string)' has some invalid arguments

Imran.

Brock Allen said:
Change:
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

To:

<%# Get20WordDescription(((DataRowView)Container.DataItem)["sItemDesc"])%>

and add a method in your page:

protected string Get20WordDescription(string val)
{
string[] parts = val.Split(' ');
if (parts.Length > 20)
{
string[] subParts = new string[20];
parts.CopyTo(subParts);
return String.Concat(subParts);
}
return val;
}

My Get20WordDescription is very much a hack, so if you spend some time I'm
sure you can come up with something much better.




Hello All,
I use a repeater control to display data, here is line I use to
output
data
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

now the issue is that this is a description field and I only want to
display the first twenty words of the description, how can I do that ?
can I alter the above command to do that, or do I need to do that in
SQL ?

Imran.
 
I

Imran Aziz

For further info, I am using the latest beta 2 release of .net framework.
Imran.

Brock Allen said:
Change:
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

To:

<%# Get20WordDescription(((DataRowView)Container.DataItem)["sItemDesc"])%>

and add a method in your page:

protected string Get20WordDescription(string val)
{
string[] parts = val.Split(' ');
if (parts.Length > 20)
{
string[] subParts = new string[20];
parts.CopyTo(subParts);
return String.Concat(subParts);
}
return val;
}

My Get20WordDescription is very much a hack, so if you spend some time I'm
sure you can come up with something much better.




Hello All,
I use a repeater control to display data, here is line I use to
output
data
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

now the issue is that this is a description field and I only want to
display the first twenty words of the description, how can I do that ?
can I alter the above command to do that, or do I need to do that in
SQL ?

Imran.
 
B

Brock Allen

Oh yea -- do this instead (I'm assuming the column is a string and is never
DB null):

Get20WordDescription((((DataRowView)Container.DataItem)["sItemDesc"]).ToString())%>




Thank you so very much Brock for coming back to me again :)
I tried this one out, and get this error for some strange reason, any
tips
as to why this is happening and how to sort it out?
Error 2 The best overloaded method match for
'showitems.Get20WordDescription(string)' has some invalid arguments

Imran.

Change:
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>
To:

<%#
Get20WordDescription(((DataRowView)Container.DataItem)["sItemDesc"])%

and add a method in your page:

protected string Get20WordDescription(string val)
{
string[] parts = val.Split(' ');
if (parts.Length > 20)
{
string[] subParts = new string[20];
parts.CopyTo(subParts);
return String.Concat(subParts);
}
return val;
}
My Get20WordDescription is very much a hack, so if you spend some
time I'm sure you can come up with something much better.

Hello All,
I use a repeater control to display data, here is line I use to
output
data
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>
now the issue is that this is a description field and I only want to
display the first twenty words of the description, how can I do that
? can I alter the above command to do that, or do I need to do that
in SQL ?

Imran.
 
I

Imran Aziz

Thanks a lot Brock that worked like a charm :)
Imran.
Brock Allen said:
Oh yea -- do this instead (I'm assuming the column is a string and is
never DB null):

Get20WordDescription((((DataRowView)Container.DataItem)["sItemDesc"]).ToString())%>




Thank you so very much Brock for coming back to me again :)
I tried this one out, and get this error for some strange reason, any
tips
as to why this is happening and how to sort it out?
Error 2 The best overloaded method match for
'showitems.Get20WordDescription(string)' has some invalid arguments

Imran.

Change:

<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>

To:

<%#
Get20WordDescription(((DataRowView)Container.DataItem)["sItemDesc"])%


and add a method in your page:

protected string Get20WordDescription(string val)
{
string[] parts = val.Split(' ');
if (parts.Length > 20)
{
string[] subParts = new string[20];
parts.CopyTo(subParts);
return String.Concat(subParts);
}
return val;
}
My Get20WordDescription is very much a hack, so if you spend some
time I'm sure you can come up with something much better.


Hello All,
I use a repeater control to display data, here is line I use to
output
data
<%# ((DataRowView)Container.DataItem)["sItemDesc"]%>
now the issue is that this is a description field and I only want to
display the first twenty words of the description, how can I do that
? can I alter the above command to do that, or do I need to do that
in SQL ?

Imran.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top