datagrid if thens

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor Hartman

    datagrid if thens

    hi,
    I want to display certain data in my edititemtemplat e 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.Data Item, "column") %>, and i can't
    include an if then in the <%# %> block. any suggestions?
    thanks
    -trevor


  • Steve C. Orr, MCSD

    #2
    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:


    --
    I hope this helps,
    Steve C. Orr, MCSD



    "Trevor Hartman" <synapsee@hotma il.com> wrote in message
    news:uUu04PvUDH A.2104@TK2MSFTN GP10.phx.gbl...[color=blue]
    > hi,
    > I want to display certain data in my edititemtemplat e in the datagrid[/color]
    based[color=blue]
    > 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.Data Item, "column") %>, and i can't
    > include an if then in the <%# %> block. any suggestions?
    > thanks
    > -trevor
    >
    >[/color]


    Comment

    • Trevor Hartman

      #3
      thanks everyone! &gt;eop



      Comment

      • Severin

        #4
        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.DataI tem("picpath") %>'
        visible='<%# IIf(Container.D ataItem("picpat h") 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@hotma il.com> wrote in message
        news:uUu04PvUDH A.2104@TK2MSFTN GP10.phx.gbl...[color=blue]
        > hi,
        > I want to display certain data in my edititemtemplat e in the datagrid[/color]
        based[color=blue]
        > 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.Data Item, "column") %>, and i can't
        > include an if then in the <%# %> block. any suggestions?
        > thanks
        > -trevor
        >
        >[/color]


        Comment

        • Saravana

          #5
          Re: broken link?

          It is




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


          "Trevor Hartman" <synapsee@hotma il.com> wrote in message
          news:#xhZWJPVDH A.3924@tk2msftn gp13.phx.gbl...[color=blue]
          >
          > "Saravana" <saravank@sct.c o.in> wrote in message
          > news:O2MQx20UDH A.2364@TK2MSFTN GP09.phx.gbl...[color=green]
          > > Check out this article,
          > >[/color]
          >[/color]
          http://www.microsoft.com/india/msdn/...rQuestions.asp[color=blue][color=green]
          > > x
          > >
          > > --
          > > Saravana
          > > Microsoft India Community Star,
          > > MCAD,SE,SD,DBA.
          > >
          > >
          > > "Trevor Hartman" <synapsee@hotma il.com> wrote in message
          > > news:uUu04PvUDH A.2104@TK2MSFTN GP10.phx.gbl...[color=darkred]
          > > > hi,
          > > > I want to display certain data in my edititemtemplat e in the datagrid[/color]
          > > based[color=darkred]
          > > > on the value of a column. How do I do an if then inside the datagrid[/color][/color]
          > AND[color=green][color=darkred]
          > > > test the value of the current column. i only know how to refer to[/color][/color]
          > columsn[color=green][color=darkred]
          > > > with the <%# DataBinder.Eval (Container.Data Item, "column") %>, and i[/color][/color]
          > can't[color=green][color=darkred]
          > > > include an if then in the <%# %> block. any suggestions?
          > > > thanks
          > > > -trevor
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...