DataList row text

Discussion in 'ASP .Net Web Controls' started by Colin Basterfield, Jun 10, 2004.

  1. 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
     
    Colin Basterfield, Jun 10, 2004
    #1
    1. Advertising

  2. 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

    "Colin Basterfield" <> wrote in message
    news:...
    > 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
    >
    >
     
    Colin Basterfield, Jun 13, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gönen EREN

    Datalist in Datalist How?

    Gönen EREN, Aug 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    413
    Gönen EREN
    Aug 22, 2003
  2. acko bogicevic

    DataList in DataList

    acko bogicevic, Nov 10, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,517
    acko bogicevic
    Nov 11, 2003
  3. Nevyn Twyll
    Replies:
    8
    Views:
    1,882
  4. H5N1
    Replies:
    0
    Views:
    2,723
  5. D
    Replies:
    0
    Views:
    220
Loading...

Share This Page