Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Programmatically alter DataList Items appearance


Message #1 by "Jon Hilton" <jmh@s...> on Tue, 26 Feb 2002 15:30:27 -0000
This is a multi-part message in MIME format.



------=_NextPart_000_000F_01C1BEDA.846257B0

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



      Hi all



      I need to be able to set a datalist item's font and style etc.

      programmatically depending on a field in a database.



      e.g. if dbfield "type" contains a h, display this record as a 

heading,

      whist n should be displayed as Verdana size 12 etc.



      Thus far, my attempts at this have revolved around a label control

      (lblResults) within the ItemTemplate of the datalist. The 

datalist's

      "OnItemCreated" points to a sub in a code-behind that contains the

      following:



      lblResults.Font.Size =3D New FontUnit(10)



      I then plan to contain this within an If or possibly Select 

statement,

      to dictate different fonts or styles depening on the database 

field

      value



      But I keep on getting the error:

      System.NullReferenceException: Object reference not set to an 

instance

      of an object



      Any thoughts?!



      Jon Hilton

      Web Co-ordinator

      Shrewsbury Sixth Form College

    









  Return to Index