DataList row text

C

Colin Basterfield

Hi,

I have a datalist which has a complete list of possible names and a check
box declared in the ItemTemplate. I get the name using the standard
mechanism:

Convert.ToString(DataBinder.Eval(Container.DataItem,"RevenueName"))

At the time of populating the grid I don't care whether the chckbox is
checked or not, I do that afterwards once I have got the site which has its
own internal list of selected names.

I am then attempting to iterate thro the datalist items:

for (int i = 0; i < dlRevAssoc.Items.Count; i++)

revName = (dlRevAssoc.Items.Controls[0] as
DataBoundLiteralControl).Text;

and as can be seen above all I want initially is the Text relating to the
name, to use to find it in my Site specific list but the text that gets
assigned to the string 'revName' is encased in \r\n\t\t\t\t\t\t\, i.e.
either side e.g.

\r\n\t\t\t\t\t\t\Adventure Park\r\n\t\t\t\t\t\t\

I am struggling to see how I can get just the text, e.g. Adventure Park?

Obviously there must be lots of other ways to do the whole thing but I don't
want to break my domain model.

Many thanks in advance

Colin B
 
C

Colin Basterfield

Well solved my own problem, all I neded to do was declare a label inside the
item template which the Convert... is assigned to the labels Text property.

The iteration thro the list items can then be done using

Label revLabel;
string revName;
for (int i = 0; i < dlRevAssoc.Items.Count; i++)

revLabel = (Label)dlRevAssoc.Items.FindControl(lblRevName)
if (revLable != null)
revName = revLabel.Text;
etc etc

Simple really, but not when there are too many trees thro which to see the
wood.

Cheers
Colin B
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top