dynamic hiding/showing of template column

Discussion in 'ASP .Net' started by beccak, May 28, 2004.

  1. beccak

    beccak Guest

    Hi,
    I'm trying to hide a template column in a datagrid then later show it. I've
    tried setting the visibility to false, but this doesn't let me get to the
    underlying data in the column. I've tried wrapping divs around the data and
    setting the div's style to display:none, but this leaves visible empty grid
    lines and I can't get the header to show/hide like it should.

    Now I'm trying like this:
    <style type="text/css">
    NowYouSeeIt { Display: block }
    NowYouDont { Display: none }
    </style>

    <asp:TemplateColumn HeaderText="Client ID"
    HeaderStyle-CssClass="NowYouDont">
    <ItemStyle CssClass="NowYouDont"></ItemStyle>
    <ItemTemplate>
    <asp:TextBox id="txtItemClientID" runat="server" Width="100px" Text='<%#
    DataBinder.Eval(Container, "DataItem.client_id") %>'>
    </asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>

    And I should be able to do things like this now in the code behind:
    dg.Columns(CLIENT_COL_POSITION).ItemStyle.CssClass = "NowYouDo"

    Not only does the templated column still display initially even with the
    style sheet, but it doesn't respond to attempts to change it in the code
    behind.
    Anyone know what is going on here?

    I've also tried using ItemStyle with the column width, but this doesn't seem
    to work either.
    Thanks.
     
    beccak, May 28, 2004
    #1
    1. Advertising

  2. Hi

    Spot the difference

    <style type="text/css">
    ..NowYouSeeIt{ Display: block }
    ..NowYouDont{ Display: none }
    </style>

    More info
    http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Visual: Scripting MVP 2000-2004
    http://www.icysoft.com/
    http://www.deus-x.com/ Instant e-commerce
    http://www.microsoft.com/technet/scriptcenter/
    Playground: http://213.190.104.211/ ( IE 5.5+ only )

    No matter where you go there you are
    ==============================
    "beccak" <> wrote in message
    news:...
    > Hi,
    > I'm trying to hide a template column in a datagrid then later show it.
    > I've
    > tried setting the visibility to false, but this doesn't let me get to the
    > underlying data in the column. I've tried wrapping divs around the data
    > and
    > setting the div's style to display:none, but this leaves visible empty
    > grid
    > lines and I can't get the header to show/hide like it should.
    >
    > Now I'm trying like this:
    > <style type="text/css">
    > NowYouSeeIt { Display: block }
    > NowYouDont { Display: none }
    > </style>
    >
    > <asp:TemplateColumn HeaderText="Client ID"
    > HeaderStyle-CssClass="NowYouDont">
    > <ItemStyle CssClass="NowYouDont"></ItemStyle>
    > <ItemTemplate>
    > <asp:TextBox id="txtItemClientID" runat="server" Width="100px"
    > Text='<%#
    > DataBinder.Eval(Container, "DataItem.client_id") %>'>
    > </asp:TextBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > And I should be able to do things like this now in the code behind:
    > dg.Columns(CLIENT_COL_POSITION).ItemStyle.CssClass = "NowYouDo"
    >
    > Not only does the templated column still display initially even with the
    > style sheet, but it doesn't respond to attempts to change it in the code
    > behind.
    > Anyone know what is going on here?
    >
    > I've also tried using ItemStyle with the column width, but this doesn't
    > seem
    > to work either.
    > Thanks.
    >
    >
     
    Vidar Petursson, May 28, 2004
    #2
    1. Advertising

  3. beccak

    beccak Guest

    Thanks for the reply. You're saying leaving out the period causes the whole
    thing not to work? I clicked on your link, but it is pretty broad. I have
    to admit I normally don't use style sheets. Thanks.

    "Vidar Petursson" <> wrote in
    message news:e2C%...
    > Hi
    >
    > Spot the difference
    >
    > <style type="text/css">
    > .NowYouSeeIt{ Display: block }
    > .NowYouDont{ Display: none }
    > </style>
    >
    > More info
    >

    http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp
    >
    > --
    > Best Regards
    > Vidar Petursson
    > ==============================
    > Microsoft Visual: Scripting MVP 2000-2004
    > http://www.icysoft.com/
    > http://www.deus-x.com/ Instant e-commerce
    > http://www.microsoft.com/technet/scriptcenter/
    > Playground: http://213.190.104.211/ ( IE 5.5+ only )
    >
    > No matter where you go there you are
    > ==============================
    > "beccak" <> wrote in message
    > news:...
    > > Hi,
    > > I'm trying to hide a template column in a datagrid then later show it.
    > > I've
    > > tried setting the visibility to false, but this doesn't let me get to

    the
    > > underlying data in the column. I've tried wrapping divs around the data
    > > and
    > > setting the div's style to display:none, but this leaves visible empty
    > > grid
    > > lines and I can't get the header to show/hide like it should.
    > >
    > > Now I'm trying like this:
    > > <style type="text/css">
    > > NowYouSeeIt { Display: block }
    > > NowYouDont { Display: none }
    > > </style>
    > >
    > > <asp:TemplateColumn HeaderText="Client ID"
    > > HeaderStyle-CssClass="NowYouDont">
    > > <ItemStyle CssClass="NowYouDont"></ItemStyle>
    > > <ItemTemplate>
    > > <asp:TextBox id="txtItemClientID" runat="server" Width="100px"
    > > Text='<%#
    > > DataBinder.Eval(Container, "DataItem.client_id") %>'>
    > > </asp:TextBox>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > >
    > > And I should be able to do things like this now in the code behind:
    > > dg.Columns(CLIENT_COL_POSITION).ItemStyle.CssClass = "NowYouDo"
    > >
    > > Not only does the templated column still display initially even with the
    > > style sheet, but it doesn't respond to attempts to change it in the code
    > > behind.
    > > Anyone know what is going on here?
    > >
    > > I've also tried using ItemStyle with the column width, but this doesn't
    > > seem
    > > to work either.
    > > Thanks.
    > >
    > >

    >
    >
     
    beccak, May 29, 2004
    #3
  4. Hi

    Yea, don't take my word for it... just try it :)

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Visual: Scripting MVP 2000-2004
    http://www.icysoft.com/
    http://www.deus-x.com/ Instant e-commerce
    http://www.microsoft.com/technet/scriptcenter/
    Playground: http://213.190.104.211/ ( IE 5.5+ only )

    No matter where you go there you are
    ==============================
    "beccak" <> wrote in message
    news:...
    > Thanks for the reply. You're saying leaving out the period causes the
    > whole
    > thing not to work? I clicked on your link, but it is pretty broad. I
    > have
    > to admit I normally don't use style sheets. Thanks.
    >
    > "Vidar Petursson" <> wrote in
    > message news:e2C%...
    >> Hi
    >>
    >> Spot the difference
    >>
    >> <style type="text/css">
    >> .NowYouSeeIt{ Display: block }
    >> .NowYouDont{ Display: none }
    >> </style>
    >>
    >> More info
    >>

    > http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp
    >>
    >> --
    >> Best Regards
    >> Vidar Petursson
    >> ==============================
    >> Microsoft Visual: Scripting MVP 2000-2004
    >> http://www.icysoft.com/
    >> http://www.deus-x.com/ Instant e-commerce
    >> http://www.microsoft.com/technet/scriptcenter/
    >> Playground: http://213.190.104.211/ ( IE 5.5+ only )
    >>
    >> No matter where you go there you are
    >> ==============================
    >> "beccak" <> wrote in message
    >> news:...
    >> > Hi,
    >> > I'm trying to hide a template column in a datagrid then later show it.
    >> > I've
    >> > tried setting the visibility to false, but this doesn't let me get to

    > the
    >> > underlying data in the column. I've tried wrapping divs around the data
    >> > and
    >> > setting the div's style to display:none, but this leaves visible empty
    >> > grid
    >> > lines and I can't get the header to show/hide like it should.
    >> >
    >> > Now I'm trying like this:
    >> > <style type="text/css">
    >> > NowYouSeeIt { Display: block }
    >> > NowYouDont { Display: none }
    >> > </style>
    >> >
    >> > <asp:TemplateColumn HeaderText="Client ID"
    >> > HeaderStyle-CssClass="NowYouDont">
    >> > <ItemStyle CssClass="NowYouDont"></ItemStyle>
    >> > <ItemTemplate>
    >> > <asp:TextBox id="txtItemClientID" runat="server" Width="100px"
    >> > Text='<%#
    >> > DataBinder.Eval(Container, "DataItem.client_id") %>'>
    >> > </asp:TextBox>
    >> > </ItemTemplate>
    >> > </asp:TemplateColumn>
    >> >
    >> > And I should be able to do things like this now in the code behind:
    >> > dg.Columns(CLIENT_COL_POSITION).ItemStyle.CssClass = "NowYouDo"
    >> >
    >> > Not only does the templated column still display initially even with
    >> > the
    >> > style sheet, but it doesn't respond to attempts to change it in the
    >> > code
    >> > behind.
    >> > Anyone know what is going on here?
    >> >
    >> > I've also tried using ItemStyle with the column width, but this doesn't
    >> > seem
    >> > to work either.
    >> > Thanks.
    >> >
    >> >

    >>
    >>

    >
    >
     
    Vidar Petursson, May 29, 2004
    #4
  5. beccak

    beccak Guest

    That did it! Thanks so much!!

    "Vidar Petursson" <> wrote in
    message news:...
    > Hi
    >
    > Yea, don't take my word for it... just try it :)
    >
    > --
    > Best Regards
    > Vidar Petursson
    > ==============================
    > Microsoft Visual: Scripting MVP 2000-2004
    > http://www.icysoft.com/
    > http://www.deus-x.com/ Instant e-commerce
    > http://www.microsoft.com/technet/scriptcenter/
    > Playground: http://213.190.104.211/ ( IE 5.5+ only )
    >
    > No matter where you go there you are
    > ==============================
    > "beccak" <> wrote in message
    > news:...
    > > Thanks for the reply. You're saying leaving out the period causes the
    > > whole
    > > thing not to work? I clicked on your link, but it is pretty broad. I
    > > have
    > > to admit I normally don't use style sheets. Thanks.
    > >
    > > "Vidar Petursson" <> wrote in
    > > message news:e2C%...
    > >> Hi
    > >>
    > >> Spot the difference
    > >>
    > >> <style type="text/css">
    > >> .NowYouSeeIt{ Display: block }
    > >> .NowYouDont{ Display: none }
    > >> </style>
    > >>
    > >> More info
    > >>

    > >

    http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp
    > >>
    > >> --
    > >> Best Regards
    > >> Vidar Petursson
    > >> ==============================
    > >> Microsoft Visual: Scripting MVP 2000-2004
    > >> http://www.icysoft.com/
    > >> http://www.deus-x.com/ Instant e-commerce
    > >> http://www.microsoft.com/technet/scriptcenter/
    > >> Playground: http://213.190.104.211/ ( IE 5.5+ only )
    > >>
    > >> No matter where you go there you are
    > >> ==============================
    > >> "beccak" <> wrote in message
    > >> news:...
    > >> > Hi,
    > >> > I'm trying to hide a template column in a datagrid then later show

    it.
    > >> > I've
    > >> > tried setting the visibility to false, but this doesn't let me get to

    > > the
    > >> > underlying data in the column. I've tried wrapping divs around the

    data
    > >> > and
    > >> > setting the div's style to display:none, but this leaves visible

    empty
    > >> > grid
    > >> > lines and I can't get the header to show/hide like it should.
    > >> >
    > >> > Now I'm trying like this:
    > >> > <style type="text/css">
    > >> > NowYouSeeIt { Display: block }
    > >> > NowYouDont { Display: none }
    > >> > </style>
    > >> >
    > >> > <asp:TemplateColumn HeaderText="Client ID"
    > >> > HeaderStyle-CssClass="NowYouDont">
    > >> > <ItemStyle CssClass="NowYouDont"></ItemStyle>
    > >> > <ItemTemplate>
    > >> > <asp:TextBox id="txtItemClientID" runat="server" Width="100px"
    > >> > Text='<%#
    > >> > DataBinder.Eval(Container, "DataItem.client_id") %>'>
    > >> > </asp:TextBox>
    > >> > </ItemTemplate>
    > >> > </asp:TemplateColumn>
    > >> >
    > >> > And I should be able to do things like this now in the code behind:
    > >> > dg.Columns(CLIENT_COL_POSITION).ItemStyle.CssClass = "NowYouDo"
    > >> >
    > >> > Not only does the templated column still display initially even with
    > >> > the
    > >> > style sheet, but it doesn't respond to attempts to change it in the
    > >> > code
    > >> > behind.
    > >> > Anyone know what is going on here?
    > >> >
    > >> > I've also tried using ItemStyle with the column width, but this

    doesn't
    > >> > seem
    > >> > to work either.
    > >> > Thanks.
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
     
    beccak, Jun 9, 2004
    #5
    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. John Kraft
    Replies:
    1
    Views:
    405
    S. Justin Gengo
    Aug 15, 2003
  2. Amber
    Replies:
    1
    Views:
    630
    Alvin Bruney
    Oct 11, 2003
  3. mathieu
    Replies:
    7
    Views:
    333
    mathieu
    Sep 10, 2006
  4. er
    Replies:
    1
    Views:
    344
  5. Ste
    Replies:
    41
    Views:
    814
    Thomas 'PointedEars' Lahn
    Aug 1, 2007
Loading...

Share This Page