Results 1 to 2 of 2

Thread: how to deal with controls inside datalist

  1. #1

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539

    how to deal with controls inside datalist

    Hey All

    how can i handle acting with controls inside datalist
    i would like to be able to make buttons and controls visable and invisable from the code behind but i havnt got a cue how to do this

    Code examples would be nice

    thanks in advance
    Last edited by carlblanchard; Mar 1st, 2005 at 03:29 PM.
    I am curretly building a defect management system for software and web developers,
    If you wana try it out (beta test) and keep it for free just send me a message

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: how to deal with controls inside datalist

    The datalist has a collection of DataListItems that contain each item within your datalist. You can access controls within each item by using the FindControl method and then assign the properties you need.

    For example if I wanted to set a button control in the 3rd item of a datalist to be hidden I would do:
    Code:
    Button btnExample = (Button) dlstExample.Items[2].FindControl("button");
    btnExample.Visible = false;
    where
    Code:
    <datalist id="dlstExample" runat="server">
    	<ItemTemplate>
    		<asp:Button id="button" runat="server" Text="Test" />
    	</ItemTemplate>
    </datalist>
    HTH

    DJ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width