Empty DataGrid Formatting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Wieder

    #1

    Empty DataGrid Formatting

    Hi - I have a datagrid that has a black header and the rows alternate
    white and gray. The problem is that until items are added to the grid,
    the grid appears as a large black rectangle, which is quite ugly. The
    black area is larger then it is once an item is added. How can I solve
    this problem either by:
    A) Having only the header black and the rest of the empty block white or
    gray (preffered solution)
    B) Having the color gray or white until an item is added and then
    changing to my default template colors - this is less ideal since I
    would aslo then have to keep track of if all times are deleted and I go
    back to the empty state.

    thanks!

  • alien2_51

    #2
    Re: Empty DataGrid Formatting

    I believe you go into the Property Builder if it's an ASP.NET grid and
    explicitily set the Header height....


    "Matthew Wieder" <Development@Sa toriGroupInc.co m> wrote in message
    news:OvcxXBOYDH A.2524@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi - I have a datagrid that has a black header and the rows alternate
    > white and gray. The problem is that until items are added to the grid,
    > the grid appears as a large black rectangle, which is quite ugly. The
    > black area is larger then it is once an item is added. How can I solve
    > this problem either by:
    > A) Having only the header black and the rest of the empty block white or
    > gray (preffered solution)
    > B) Having the color gray or white until an item is added and then
    > changing to my default template colors - this is less ideal since I
    > would aslo then have to keep track of if all times are deleted and I go
    > back to the empty state.
    >
    > thanks!
    >[/color]


    Comment

    • Matthew Wieder

      #3
      Re: Empty DataGrid Formatting

      I'm not sure what version of VS you're using, but in mine, property
      builder doesn't allow setting of the height for the header...
      anyone else?

      alien2_51 wrote:
      [color=blue]
      > I believe you go into the Property Builder if it's an ASP.NET grid and
      > explicitily set the Header height....
      >
      >
      > "Matthew Wieder" <Development@Sa toriGroupInc.co m> wrote in message
      > news:OvcxXBOYDH A.2524@TK2MSFTN GP09.phx.gbl...
      >[color=green]
      >>Hi - I have a datagrid that has a black header and the rows alternate
      >>white and gray. The problem is that until items are added to the grid,
      >>the grid appears as a large black rectangle, which is quite ugly. The
      >>black area is larger then it is once an item is added. How can I solve
      >>this problem either by:
      >>A) Having only the header black and the rest of the empty block white or
      >>gray (preffered solution)
      >>B) Having the color gray or white until an item is added and then
      >>changing to my default template colors - this is less ideal since I
      >>would aslo then have to keep track of if all times are deleted and I go
      >>back to the empty state.
      >>
      >>thanks!
      >>[/color]
      >
      >
      >[/color]

      Comment

      • Yan-Hong Huang[MSFT]

        #4
        Re: Empty DataGrid Formatting

        Hello Matthew,

        Thanks for posting in the group.

        1) for changing header color:
        we could use the following in design time:
        <asp:DataGrid ID="DefaultGrid " Runat="server" ShowHeader=True >
        <HeaderStyle Font-Size="14px" Font-Bold="True" BackColor="Ligh tSalmon"></HeaderStyle>
        </asp:DataGrid>

        2) for row colors:
        we could implement the ItemDataBound event for the datagrid.

        // event code
        private void dGrid_ItemDataB ound(object sender,
        System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
        // only apply on item and alternating item
        if (e.Item.ItemTyp e == ListItemType.It em ||
        e.Item.ItemType == ListItemType.Al ternatingItem)
        {
        // getting the index value ( or any other data cell
        value )
        string sVal = e.Item.Cells[0].Text;

        // changing the color or all even rows
        if ((Convert.ToInt 32(sVal) == 3)
        {
        e.Item.BackColo r = System.Drawing. Color.Red;
        }
        }
        }

        You can try this also:
        After binding the dataset to the datagrid.
        just try this piece of code:
        datagrid1.items[3].BackColor=Syst em.Drawing.Colo r.Red.

        Hope it helps.

        Best regards,
        Yanhong Huang
        Microsoft Online Partner Support

        Get Secure! - www.microsoft.com/security
        This posting is provided "AS IS" with no warranties, and confers no rights.

        --------------------
        !Date: Tue, 12 Aug 2003 11:32:21 -0400
        !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
        !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
        !X-Accept-Language: en-us, en, he
        !MIME-Version: 1.0
        !Subject: Re: Empty DataGrid Formatting
        !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl> <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
        !In-Reply-To: <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
        !Content-Type: text/plain; charset=us-ascii; format=flowed
        !Content-Transfer-Encoding: 7bit
        !Message-ID: <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl>
        !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
        !NNTP-Posting-Host: 207.106.112.178
        !Lines: 1
        !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
        !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1671 21
        !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
        !
        !I'm not sure what version of VS you're using, but in mine, property
        !builder doesn't allow setting of the height for the header...
        !anyone else?
        !
        !alien2_51 wrote:
        !
        !> I believe you go into the Property Builder if it's an ASP.NET grid and
        !> explicitily set the Header height....
        !>
        !>
        !> "Matthew Wieder" <Development@Sa toriGroupInc.co m> wrote in message
        !> news:OvcxXBOYDH A.2524@TK2MSFTN GP09.phx.gbl...
        !>
        !>>Hi - I have a datagrid that has a black header and the rows alternate
        !>>white and gray. The problem is that until items are added to the grid,
        !>>the grid appears as a large black rectangle, which is quite ugly. The
        !>>black area is larger then it is once an item is added. How can I solve
        !>>this problem either by:
        !>>A) Having only the header black and the rest of the empty block white or
        !>>gray (preffered solution)
        !>>B) Having the color gray or white until an item is added and then
        !>>changing to my default template colors - this is less ideal since I
        !>>would aslo then have to keep track of if all times are deleted and I go
        !>>back to the empty state.
        !>>
        !>>thanks!
        !>>
        !>
        !>
        !>
        !
        !


        Comment

        • Matthew Wieder

          #5
          Re: Empty DataGrid Formatting

          I'm not sure you understand the issue - when an ASP.NET datagrid is
          empty, whatever background color set for the header "spreads" to the
          whole rectange, much larger then the area the header oocupies once it
          has data. I'd like a way to stop the "spreading" so that the header
          color is not over-applied to an empty grid.

          Yan-Hong Huang[MSFT] wrote:
          [color=blue]
          > Hello Matthew,
          >
          > Thanks for posting in the group.
          >
          > 1) for changing header color:
          > we could use the following in design time:
          > <asp:DataGrid ID="DefaultGrid " Runat="server" ShowHeader=True >
          > <HeaderStyle Font-Size="14px" Font-Bold="True" BackColor="Ligh tSalmon"></HeaderStyle>
          > </asp:DataGrid>
          >
          > 2) for row colors:
          > we could implement the ItemDataBound event for the datagrid.
          >
          > // event code
          > private void dGrid_ItemDataB ound(object sender,
          > System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
          > // only apply on item and alternating item
          > if (e.Item.ItemTyp e == ListItemType.It em ||
          > e.Item.ItemType == ListItemType.Al ternatingItem)
          > {
          > // getting the index value ( or any other data cell
          > value )
          > string sVal = e.Item.Cells[0].Text;
          >
          > // changing the color or all even rows
          > if ((Convert.ToInt 32(sVal) == 3)
          > {
          > e.Item.BackColo r = System.Drawing. Color.Red;
          > }
          > }
          > }
          >
          > You can try this also:
          > After binding the dataset to the datagrid.
          > just try this piece of code:
          > datagrid1.items[3].BackColor=Syst em.Drawing.Colo r.Red.
          >
          > Hope it helps.
          >
          > Best regards,
          > Yanhong Huang
          > Microsoft Online Partner Support
          >
          > Get Secure! - www.microsoft.com/security
          > This posting is provided "AS IS" with no warranties, and confers no rights.
          >
          > --------------------
          > !Date: Tue, 12 Aug 2003 11:32:21 -0400
          > !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
          > !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
          > !X-Accept-Language: en-us, en, he
          > !MIME-Version: 1.0
          > !Subject: Re: Empty DataGrid Formatting
          > !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl> <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
          > !In-Reply-To: <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
          > !Content-Type: text/plain; charset=us-ascii; format=flowed
          > !Content-Transfer-Encoding: 7bit
          > !Message-ID: <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl>
          > !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
          > !NNTP-Posting-Host: 207.106.112.178
          > !Lines: 1
          > !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
          > !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1671 21
          > !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
          > !
          > !I'm not sure what version of VS you're using, but in mine, property
          > !builder doesn't allow setting of the height for the header...
          > !anyone else?
          > !
          > !alien2_51 wrote:
          > !
          > !> I believe you go into the Property Builder if it's an ASP.NET grid and
          > !> explicitily set the Header height....
          > !>
          > !>
          > !> "Matthew Wieder" <Development@Sa toriGroupInc.co m> wrote in message
          > !> news:OvcxXBOYDH A.2524@TK2MSFTN GP09.phx.gbl...
          > !>
          > !>>Hi - I have a datagrid that has a black header and the rows alternate
          > !>>white and gray. The problem is that until items are added to the grid,
          > !>>the grid appears as a large black rectangle, which is quite ugly. The
          > !>>black area is larger then it is once an item is added. How can I solve
          > !>>this problem either by:
          > !>>A) Having only the header black and the rest of the empty block white or
          > !>>gray (preffered solution)
          > !>>B) Having the color gray or white until an item is added and then
          > !>>changing to my default template colors - this is less ideal since I
          > !>>would aslo then have to keep track of if all times are deleted and I go
          > !>>back to the empty state.
          > !>>
          > !>>thanks!
          > !>>
          > !>
          > !>
          > !>
          > !
          > !
          >
          >[/color]

          Comment

          • Ram

            #6
            Re: Empty DataGrid Formatting

            Matthew,

            Correct me if I could not understand your problem properly.

            When you don't have any data in the datagrid, your header is spreading
            to the size of the datagrid.

            To get rid of this remove the height in the datagrid properties. By
            doing this, your datagrid will stretch to the required height,
            depending on the data.

            If you wan to have fixed datagrid height, rap it in DIV tags and
            specify height for the DIV tag.

            Hope this helps.
            Ram



            Matthew Wieder <Development@Sa toriGroupInc.co m> wrote in message news:<3F3A77A0. 1000308@SatoriG roupInc.com>...[color=blue]
            > I'm not sure you understand the issue - when an ASP.NET datagrid is
            > empty, whatever background color set for the header "spreads" to the
            > whole rectange, much larger then the area the header oocupies once it
            > has data. I'd like a way to stop the "spreading" so that the header
            > color is not over-applied to an empty grid.
            >
            > Yan-Hong Huang[MSFT] wrote:
            >[color=green]
            > > Hello Matthew,
            > >
            > > Thanks for posting in the group.
            > >
            > > 1) for changing header color:
            > > we could use the following in design time:
            > > <asp:DataGrid ID="DefaultGrid " Runat="server" ShowHeader=True >
            > > <HeaderStyle Font-Size="14px" Font-Bold="True" BackColor="Ligh tSalmon"></HeaderStyle>
            > > </asp:DataGrid>
            > >
            > > 2) for row colors:
            > > we could implement the ItemDataBound event for the datagrid.
            > >
            > > // event code
            > > private void dGrid_ItemDataB ound(object sender,
            > > System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
            > > // only apply on item and alternating item
            > > if (e.Item.ItemTyp e == ListItemType.It em ||
            > > e.Item.ItemType == ListItemType.Al ternatingItem)
            > > {
            > > // getting the index value ( or any other data cell
            > > value )
            > > string sVal = e.Item.Cells[0].Text;
            > >
            > > // changing the color or all even rows
            > > if ((Convert.ToInt 32(sVal) == 3)
            > > {
            > > e.Item.BackColo r = System.Drawing. Color.Red;
            > > }
            > > }
            > > }
            > >
            > > You can try this also:
            > > After binding the dataset to the datagrid.
            > > just try this piece of code:
            > > datagrid1.items[3].BackColor=Syst em.Drawing.Colo r.Red.
            > >
            > > Hope it helps.
            > >
            > > Best regards,
            > > Yanhong Huang
            > > Microsoft Online Partner Support
            > >
            > > Get Secure! - www.microsoft.com/security
            > > This posting is provided "AS IS" with no warranties, and confers no rights.
            > >
            > > --------------------
            > > !Date: Tue, 12 Aug 2003 11:32:21 -0400
            > > !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
            > > !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
            > > !X-Accept-Language: en-us, en, he
            > > !MIME-Version: 1.0
            > > !Subject: Re: Empty DataGrid Formatting
            > > !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl> <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
            > > !In-Reply-To: <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
            > > !Content-Type: text/plain; charset=us-ascii; format=flowed
            > > !Content-Transfer-Encoding: 7bit
            > > !Message-ID: <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl>
            > > !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
            > > !NNTP-Posting-Host: 207.106.112.178
            > > !Lines: 1
            > > !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
            > > !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1671 21
            > > !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
            > > !
            > > !I'm not sure what version of VS you're using, but in mine, property
            > > !builder doesn't allow setting of the height for the header...
            > > !anyone else?
            > > !
            > > !alien2_51 wrote:
            > > !
            > > !> I believe you go into the Property Builder if it's an ASP.NET grid and
            > > !> explicitily set the Header height....
            > > !>
            > > !>
            > > !> "Matthew Wieder" <Development@Sa toriGroupInc.co m> wrote in message
            > > !> news:OvcxXBOYDH A.2524@TK2MSFTN GP09.phx.gbl...
            > > !>
            > > !>>Hi - I have a datagrid that has a black header and the rows alternate
            > > !>>white and gray. The problem is that until items are added to the grid,
            > > !>>the grid appears as a large black rectangle, which is quite ugly. The
            > > !>>black area is larger then it is once an item is added. How can I solve
            > > !>>this problem either by:
            > > !>>A) Having only the header black and the rest of the empty block white or
            > > !>>gray (preffered solution)
            > > !>>B) Having the color gray or white until an item is added and then
            > > !>>changing to my default template colors - this is less ideal since I
            > > !>>would aslo then have to keep track of if all times are deleted and I go
            > > !>>back to the empty state.
            > > !>>
            > > !>>thanks!
            > > !>>
            > > !>
            > > !>
            > > !>
            > > !
            > > !
            > >
            > >[/color][/color]

            Comment

            • Yan-Hong Huang[MSFT]

              #7
              Re: Empty DataGrid Formatting

              Hello Matthew,

              Now I understand what you need now. :) Ram is right. If we don't set
              DataGrid's Height property, the height of the header row will return to
              normal. I have tested it on my side and it looks nice now.

              If you have follow up questions, please post here. Thanks very much.

              Best regards,
              Yanhong Huang
              Microsoft Online Partner Support

              Get Secure! ¨C www.microsoft.com/security
              This posting is provided "AS IS" with no warranties, and confers no rights.

              --------------------
              !Message-ID: <3F3A77A0.10003 08@SatoriGroupI nc.com>
              !Date: Wed, 13 Aug 2003 13:38:40 -0400
              !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
              !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4)
              Gecko/20030624 Netscape/7.1 (ax)
              !X-Accept-Language: en-us, en, he
              !MIME-Version: 1.0
              !To: "Yan-Hong Huang[MSFT]" <yhhuang@online .microsoft.com>
              !Subject: Re: Empty DataGrid Formatting
              !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl>
              <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
              <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl>
              <5n9#2UXYDHA.25 20@cpmsftngxa06 .phx.gbl>
              !In-Reply-To: <5n9#2UXYDHA.25 20@cpmsftngxa06 .phx.gbl>
              !Content-Type: text/plain; charset=us-ascii; format=flowed
              !Content-Transfer-Encoding: 7bit
              !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
              !NNTP-Posting-Host: 207.106.112.178
              !Lines: 1
              !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
              !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1675 86
              !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
              !
              !I'm not sure you understand the issue - when an ASP.NET datagrid is
              !empty, whatever background color set for the header "spreads" to the
              !whole rectange, much larger then the area the header oocupies once it
              !has data. I'd like a way to stop the "spreading" so that the header
              !color is not over-applied to an empty grid.
              !
              !Yan-Hong Huang[MSFT] wrote:
              !
              !> Hello Matthew,
              !>
              !> Thanks for posting in the group.
              !>
              !> 1) for changing header color:
              !> we could use the following in design time:
              !> <asp:DataGrid ID="DefaultGrid " Runat="server" ShowHeader=True >
              !> <HeaderStyle Font-Size="14px" Font-Bold="True"
              BackColor="Ligh tSalmon"></HeaderStyle>
              !> </asp:DataGrid>
              !>
              !> 2) for row colors:
              !> we could implement the ItemDataBound event for the datagrid.
              !>
              !> // event code
              !> private void dGrid_ItemDataB ound(object sender,
              !> System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
              !> // only apply on item and alternating item
              !> if (e.Item.ItemTyp e == ListItemType.It em ||
              !> e.Item.ItemType == ListItemType.Al ternatingItem)
              !> {
              !> // getting the index value ( or any other data cell
              !> value )
              !> string sVal = e.Item.Cells[0].Text;
              !>
              !> // changing the color or all even rows
              !> if ((Convert.ToInt 32(sVal) == 3)
              !> {
              !> e.Item.BackColo r = System.Drawing. Color.Red;
              !> }
              !> }
              !> }
              !>
              !> You can try this also:
              !> After binding the dataset to the datagrid.
              !> just try this piece of code:
              !> datagrid1.items[3].BackColor=Syst em.Drawing.Colo r.Red.
              !>
              !> Hope it helps.
              !>
              !> Best regards,
              !> Yanhong Huang
              !> Microsoft Online Partner Support
              !>
              !> Get Secure! - www.microsoft.com/security
              !> This posting is provided "AS IS" with no warranties, and confers no
              rights.
              !>
              !> --------------------
              !> !Date: Tue, 12 Aug 2003 11:32:21 -0400
              !> !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
              !> !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4)
              Gecko/20030624 Netscape/7.1 (ax)
              !> !X-Accept-Language: en-us, en, he
              !> !MIME-Version: 1.0
              !> !Subject: Re: Empty DataGrid Formatting
              !> !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl>
              <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
              !> !In-Reply-To: <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
              !> !Content-Type: text/plain; charset=us-ascii; format=flowed
              !> !Content-Transfer-Encoding: 7bit
              !> !Message-ID: <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl>
              !> !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
              !> !NNTP-Posting-Host: 207.106.112.178
              !> !Lines: 1
              !> !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
              !> !Xref: cpmsftngxa06.ph x.gbl
              microsoft.publi c.dotnet.framew ork.aspnet:1671 21
              !> !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
              !> !
              !> !I'm not sure what version of VS you're using, but in mine, property
              !> !builder doesn't allow setting of the height for the header...
              !> !anyone else?
              !> !
              !> !alien2_51 wrote:
              !> !
              !> !> I believe you go into the Property Builder if it's an ASP.NET grid and
              !> !> explicitily set the Header height....
              !> !>
              !> !>
              !> !> "Matthew Wieder" <Development@Sa toriGroupInc.co m> wrote in message
              !> !> news:OvcxXBOYDH A.2524@TK2MSFTN GP09.phx.gbl...
              !> !>
              !> !>>Hi - I have a datagrid that has a black header and the rows alternate
              !> !>>white and gray. The problem is that until items are added to the
              grid,
              !> !>>the grid appears as a large black rectangle, which is quite ugly. The
              !> !>>black area is larger then it is once an item is added. How can I
              solve
              !> !>>this problem either by:
              !> !>>A) Having only the header black and the rest of the empty block white
              or
              !> !>>gray (preffered solution)
              !> !>>B) Having the color gray or white until an item is added and then
              !> !>>changing to my default template colors - this is less ideal since I
              !> !>>would aslo then have to keep track of if all times are deleted and I
              go
              !> !>>back to the empty state.
              !> !>>
              !> !>>thanks!
              !> !>>
              !> !>
              !> !>
              !> !>
              !> !
              !> !
              !>
              !>
              !
              !

              Comment

              • Yan-Hong Huang[MSFT]

                #8
                Re: Empty DataGrid Formatting

                Hello Matthew,

                You are welcome. If you have follow up questions, please feel free to post in the group and we are glad to be of assistance.

                Thanks very much for participating the community.

                Best regards,
                Yanhong Huang
                Microsoft Online Partner Support

                Get Secure! - www.microsoft.com/security
                This posting is provided "AS IS" with no warranties, and confers no rights.

                --------------------
                !Date: Thu, 14 Aug 2003 08:56:44 -0400
                !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
                !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
                !X-Accept-Language: en-us, en, he
                !MIME-Version: 1.0
                !Subject: Re: Empty DataGrid Formatting
                !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl> <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
                <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl> <5n9#2UXYDHA.25 20@cpmsftngxa06 .phx.gbl> <3F3A77A0.10003 08
                @SatoriGroupInc .com> <p#ZZenlYDHA.19 96@cpmsftngxa06 .phx.gbl>
                !In-Reply-To: <p#ZZenlYDHA.19 96@cpmsftngxa06 .phx.gbl>
                !Content-Type: text/plain; charset=ISO-8859-1; format=flowed
                !Content-Transfer-Encoding: 8bit
                !Message-ID: <#8me5NmYDHA.20 32@TK2MSFTNGP10 .phx.gbl>
                !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
                !NNTP-Posting-Host: 207.106.112.178
                !Lines: 1
                !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
                !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1678 45
                !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
                !
                !Thanks!
                !
                !Yan-Hong Huang[MSFT] wrote:
                !> Hello Matthew,
                !>
                !> Now I understand what you need now. :) Ram is right. If we don't set
                !> DataGrid's Height property, the height of the header row will return to
                !> normal. I have tested it on my side and it looks nice now.
                !>
                !> If you have follow up questions, please post here. Thanks very much.
                !>
                !> Best regards,
                !> Yanhong Huang
                !> Microsoft Online Partner Support
                !>
                !> Get Secure! ¨C www.microsoft.com/security
                !> This posting is provided "AS IS" with no warranties, and confers no rights.
                !>
                !> --------------------
                !> !Message-ID: <3F3A77A0.10003 08@SatoriGroupI nc.com>
                !> !Date: Wed, 13 Aug 2003 13:38:40 -0400
                !> !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
                !> !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4)
                !> Gecko/20030624 Netscape/7.1 (ax)
                !> !X-Accept-Language: en-us, en, he
                !> !MIME-Version: 1.0
                !> !To: "Yan-Hong Huang[MSFT]" <yhhuang@online .microsoft.com>
                !> !Subject: Re: Empty DataGrid Formatting
                !> !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl>
                !> <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
                !> <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl>
                !> <5n9#2UXYDHA.25 20@cpmsftngxa06 .phx.gbl>
                !> !In-Reply-To: <5n9#2UXYDHA.25 20@cpmsftngxa06 .phx.gbl>
                !> !Content-Type: text/plain; charset=us-ascii; format=flowed
                !> !Content-Transfer-Encoding: 7bit
                !> !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
                !> !NNTP-Posting-Host: 207.106.112.178
                !> !Lines: 1
                !> !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
                !> !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1675 86
                !> !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
                !> !
                !> !I'm not sure you understand the issue - when an ASP.NET datagrid is
                !> !empty, whatever background color set for the header "spreads" to the
                !> !whole rectange, much larger then the area the header oocupies once it
                !> !has data. I'd like a way to stop the "spreading" so that the header
                !> !color is not over-applied to an empty grid.
                !> !
                !> !Yan-Hong Huang[MSFT] wrote:
                !> !
                !> !> Hello Matthew,
                !> !>
                !> !> Thanks for posting in the group.
                !> !>
                !> !> 1) for changing header color:
                !> !> we could use the following in design time:
                !> !> <asp:DataGrid ID="DefaultGrid " Runat="server" ShowHeader=True >
                !> !> <HeaderStyle Font-Size="14px" Font-Bold="True"
                !> BackColor="Ligh tSalmon"></HeaderStyle>
                !> !> </asp:DataGrid>
                !> !>
                !> !> 2) for row colors:
                !> !> we could implement the ItemDataBound event for the datagrid.
                !> !>
                !> !> // event code
                !> !> private void dGrid_ItemDataB ound(object sender,
                !> !> System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
                !> !> // only apply on item and alternating item
                !> !> if (e.Item.ItemTyp e == ListItemType.It em ||
                !> !> e.Item.ItemType == ListItemType.Al ternatingItem)
                !> !> {
                !> !> // getting the index value ( or any other data cell
                !> !> value )
                !> !> string sVal = e.Item.Cells[0].Text;
                !> !>
                !> !> // changing the color or all even rows
                !> !> if ((Convert.ToInt 32(sVal) == 3)
                !> !> {
                !> !> e.Item.BackColo r = System.Drawing. Color.Red;
                !> !> }
                !> !> }
                !> !> }
                !> !>
                !> !> You can try this also:
                !> !> After binding the dataset to the datagrid.
                !> !> just try this piece of code:
                !> !> datagrid1.items[3].BackColor=Syst em.Drawing.Colo r.Red.
                !> !>
                !> !> Hope it helps.
                !> !>
                !> !> Best regards,
                !> !> Yanhong Huang
                !> !> Microsoft Online Partner Support
                !> !>
                !> !> Get Secure! - www.microsoft.com/security
                !> !> This posting is provided "AS IS" with no warranties, and confers no
                !> rights.
                !> !>
                !> !> --------------------
                !> !> !Date: Tue, 12 Aug 2003 11:32:21 -0400
                !> !> !From: Matthew Wieder <Development@Sa toriGroupInc.co m>
                !> !> !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4)
                !> Gecko/20030624 Netscape/7.1 (ax)
                !> !> !X-Accept-Language: en-us, en, he
                !> !> !MIME-Version: 1.0
                !> !> !Subject: Re: Empty DataGrid Formatting
                !> !> !References: <OvcxXBOYDHA.25 24@TK2MSFTNGP09 .phx.gbl>
                !> <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
                !> !> !In-Reply-To: <#rvRYZOYDHA.23 08@TK2MSFTNGP12 .phx.gbl>
                !> !> !Content-Type: text/plain; charset=us-ascii; format=flowed
                !> !> !Content-Transfer-Encoding: 7bit
                !> !> !Message-ID: <uBD9hbOYDHA.88 8@TK2MSFTNGP10. phx.gbl>
                !> !> !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
                !> !> !NNTP-Posting-Host: 207.106.112.178
                !> !> !Lines: 1
                !> !> !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
                !> !> !Xref: cpmsftngxa06.ph x.gbl
                !> microsoft.publi c.dotnet.framew ork.aspnet:1671 21
                !> !> !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
                !> !> !
                !> !> !I'm not sure what version of VS you're using, but in mine, property
                !> !> !builder doesn't allow setting of the height for the header...
                !> !> !anyone else?
                !> !> !
                !> !> !alien2_51 wrote:
                !> !> !
                !> !> !> I believe you go into the Property Builder if it's an ASP.NET grid and
                !> !> !> explicitily set the Header height....
                !> !> !>
                !> !> !>
                !> !> !> "Matthew Wieder" <Development@Sa toriGroupInc.co m> wrote in message
                !> !> !> news:OvcxXBOYDH A.2524@TK2MSFTN GP09.phx.gbl...
                !> !> !>
                !> !> !>>Hi - I have a datagrid that has a black header and the rows alternate
                !> !> !>>white and gray. The problem is that until items are added to the
                !> grid,
                !> !> !>>the grid appears as a large black rectangle, which is quite ugly. The
                !> !> !>>black area is larger then it is once an item is added. How can I
                !> solve
                !> !> !>>this problem either by:
                !> !> !>>A) Having only the header black and the rest of the empty block white
                !> or
                !> !> !>>gray (preffered solution)
                !> !> !>>B) Having the color gray or white until an item is added and then
                !> !> !>>changing to my default template colors - this is less ideal since I
                !> !> !>>would aslo then have to keep track of if all times are deleted and I
                !> go
                !> !> !>>back to the empty state.
                !> !> !>>
                !> !> !>>thanks!
                !> !> !>>
                !> !> !>
                !> !> !>
                !> !> !>
                !> !> !
                !> !> !
                !> !>
                !> !>
                !> !
                !> !
                !>
                !
                !


                Comment

                Working...