Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default datagrid if thens

    hi,
    I want to display certain data in my edititemtemplate in the datagrid based
    on the value of a column. How do I do an if then inside the datagrid AND
    test the value of the current column. i only know how to refer to columsn
    with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i can't
    include an if then in the <%# %> block. any suggestions?
    thanks
    -trevor


    Trevor Hartman Guest

  2. Similar Questions and Discussions

    1. How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event.
      How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the...
    2. UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
      I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it resides inside a datagrid column and i set the selecteddate property of...
    3. custom usercontrol inside of datagrid - loses its state/viewstate on re-bind/postback of the datagrid
      I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it resides inside a datagrid column and i set the selecteddate property of...
    4. To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible?
      Hello, I am searching the whole Internet for a good example how to edit/update a DataGrid in a DataGrid (nested DataGrid). I know how to...
    5. easy and quick Question - relating to If, thens
      im relatively new to scripting in director and i am trying to write a script with multiple conditions on it. this is part of the second handler on...
  3. #2

    Default Re: datagrid if thens

    Seems your code would be best in the OnItemCreated event or the
    OnItemDataBound event.

    If e.Item.Cells(1).Value = 1 Then ...

    Here's more info:
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassonitemcrea tedtopic.asp[/url]

    --
    I hope this helps,
    Steve C. Orr, MCSD
    [url]http://Steve.Orr.net[/url]


    "Trevor Hartman" <synapsee@hotmail.com> wrote in message
    news:uUu04PvUDHA.2104@TK2MSFTNGP10.phx.gbl...
    > hi,
    > I want to display certain data in my edititemtemplate in the datagrid
    based
    > on the value of a column. How do I do an if then inside the datagrid AND
    > test the value of the current column. i only know how to refer to columsn
    > with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i can't
    > include an if then in the <%# %> block. any suggestions?
    > thanks
    > -trevor
    >
    >

    Steve C. Orr, MCSD Guest

  4. #3

    Default thanks everyone! >eop



    Trevor Hartman Guest

  5. #4

    Default Re: datagrid if thens

    Inside as datagrid control you can use the 'IIf([expression], True, False)'
    function...

    Any function calls in either the 'TruePart or Falsepart' will be called
    regardless of the value of [expression]

    I use this to toggle the 'visible' attribute in <asp:image /> controls in a
    datagrid or datalist like so....

    <asp:image id="imgLogo" imageUrl='<%# Container.DataItem("picpath") %>'
    visible='<%# IIf(Container.DataItem("picpath") Is DbNull.Value, "False",
    "True") %>' />

    This IIf() function toggles the image visible to 'False' if "picpath" is
    DbNull.Value, else it displays if there is a value in "picpath"

    Severin


    "Trevor Hartman" <synapsee@hotmail.com> wrote in message
    news:uUu04PvUDHA.2104@TK2MSFTNGP10.phx.gbl...
    > hi,
    > I want to display certain data in my edititemtemplate in the datagrid
    based
    > on the value of a column. How do I do an if then inside the datagrid AND
    > test the value of the current column. i only know how to refer to columsn
    > with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i can't
    > include an if then in the <%# %> block. any suggestions?
    > thanks
    > -trevor
    >
    >

    Severin Guest

  6. #5

    Default Re: broken link?

    It is
    [url]www.microsoft.com/india/msdn/articles/SolutionstoTopFourQuestions.aspx[/url]



    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "Trevor Hartman" <synapsee@hotmail.com> wrote in message
    news:#xhZWJPVDHA.3924@tk2msftngp13.phx.gbl...
    >
    > "Saravana" <saravank@sct.co.in> wrote in message
    > news:O2MQx20UDHA.2364@TK2MSFTNGP09.phx.gbl...
    > > Check out this article,
    > >
    >
    [url]http://www.microsoft.com/india/msdn/articles/SolutionstoTopFourQuestions.asp[/url]
    > > x
    > >
    > > --
    > > Saravana
    > > Microsoft India Community Star,
    > > MCAD,SE,SD,DBA.
    > >
    > >
    > > "Trevor Hartman" <synapsee@hotmail.com> wrote in message
    > > news:uUu04PvUDHA.2104@TK2MSFTNGP10.phx.gbl...
    > > > hi,
    > > > I want to display certain data in my edititemtemplate in the datagrid
    > > based
    > > > on the value of a column. How do I do an if then inside the datagrid
    > AND
    > > > test the value of the current column. i only know how to refer to
    > columsn
    > > > with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i
    > can't
    > > > include an if then in the <%# %> block. any suggestions?
    > > > thanks
    > > > -trevor
    > > >
    > > >
    > >
    > >
    >
    >

    Saravana Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139