472,325 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,325 software developers and data experts.

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!

Nov 17 '05 #1
7 4582
I believe you go into the Property Builder if it's an ASP.NET grid and
explicitily set the Header height....
"Matthew Wieder" <De*********@SatoriGroupInc.com> wrote in message
news:Ov**************@TK2MSFTNGP09.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!

Nov 17 '05 #2
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" <De*********@SatoriGroupInc.com> wrote in message
news:Ov**************@TK2MSFTNGP09.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!



Nov 17 '05 #3
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="LightSalmon"></HeaderStyle>
</asp:DataGrid>

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

// event code
private void dGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e) {
// only apply on item and alternating item
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
// 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.ToInt32(sVal) == 3)
{
e.Item.BackColor = 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=System.Drawing.Color.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 <De*********@SatoriGroupInc.com>
!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: <Ov**************@TK2MSFTNGP09.phx.gbl> <#r**************@TK2MSFTNGP12.phx.gbl>
!In-Reply-To: <#r**************@TK2MSFTNGP12.phx.gbl>
!Content-Type: text/plain; charset=us-ascii; format=flowed
!Content-Transfer-Encoding: 7bit
!Message-ID: <uB*************@TK2MSFTNGP10.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 207.106.112.178
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167121
!X-Tomcat-NG: microsoft.public.dotnet.framework.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" <De*********@SatoriGroupInc.com> wrote in message
!> news:Ov**************@TK2MSFTNGP09.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!
!>>
!>
!>
!>
!
!
Nov 17 '05 #4
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="LightSalmon"></HeaderStyle>
</asp:DataGrid>

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

// event code
private void dGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e) {
// only apply on item and alternating item
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
// 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.ToInt32(sVal) == 3)
{
e.Item.BackColor = 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=System.Drawing.Color.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 <De*********@SatoriGroupInc.com>
!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: <Ov**************@TK2MSFTNGP09.phx.gbl> <#r**************@TK2MSFTNGP12.phx.gbl>
!In-Reply-To: <#r**************@TK2MSFTNGP12.phx.gbl>
!Content-Type: text/plain; charset=us-ascii; format=flowed
!Content-Transfer-Encoding: 7bit
!Message-ID: <uB*************@TK2MSFTNGP10.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 207.106.112.178
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167121
!X-Tomcat-NG: microsoft.public.dotnet.framework.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" <De*********@SatoriGroupInc.com> wrote in message
!> news:Ov**************@TK2MSFTNGP09.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!
!>>
!>
!>
!>
!
!


Nov 17 '05 #5
Ram
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 <De*********@SatoriGroupInc.com> wrote in message news:<3F**************@SatoriGroupInc.com>...
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="LightSalmon"></HeaderStyle>
</asp:DataGrid>

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

// event code
private void dGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e) {
// only apply on item and alternating item
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
// 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.ToInt32(sVal) == 3)
{
e.Item.BackColor = 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=System.Drawing.Color.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 <De*********@SatoriGroupInc.com>
!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: <Ov**************@TK2MSFTNGP09.phx.gbl> <#r**************@TK2MSFTNGP12.phx.gbl>
!In-Reply-To: <#r**************@TK2MSFTNGP12.phx.gbl>
!Content-Type: text/plain; charset=us-ascii; format=flowed
!Content-Transfer-Encoding: 7bit
!Message-ID: <uB*************@TK2MSFTNGP10.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 207.106.112.178
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167121
!X-Tomcat-NG: microsoft.public.dotnet.framework.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" <De*********@SatoriGroupInc.com> wrote in message
!> news:Ov**************@TK2MSFTNGP09.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!
!>>
!>
!>
!>
!
!

Nov 17 '05 #6
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: <3F**************@SatoriGroupInc.com>
!Date: Wed, 13 Aug 2003 13:38:40 -0400
!From: Matthew Wieder <De*********@SatoriGroupInc.com>
!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]" <yh*****@online.microsoft.com>
!Subject: Re: Empty DataGrid Formatting
!References: <Ov**************@TK2MSFTNGP09.phx.gbl>
<#r**************@TK2MSFTNGP12.phx.gbl>
<uB*************@TK2MSFTNGP10.phx.gbl>
<5n**************@cpmsftngxa06.phx.gbl>
!In-Reply-To: <5n**************@cpmsftngxa06.phx.gbl>
!Content-Type: text/plain; charset=us-ascii; format=flowed
!Content-Transfer-Encoding: 7bit
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 207.106.112.178
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167586
!X-Tomcat-NG: microsoft.public.dotnet.framework.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="LightSalmon"></HeaderStyle>
!> </asp:DataGrid>
!>
!> 2) for row colors:
!> we could implement the ItemDataBound event for the datagrid.
!>
!> // event code
!> private void dGrid_ItemDataBound(object sender,
!> System.Web.UI.WebControls.DataGridItemEventArgs e) {
!> // only apply on item and alternating item
!> if (e.Item.ItemType == ListItemType.Item ||
!> e.Item.ItemType == ListItemType.AlternatingItem)
!> {
!> // 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.ToInt32(sVal) == 3)
!> {
!> e.Item.BackColor = 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=System.Drawing.Color.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 <De*********@SatoriGroupInc.com>
!> !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: <Ov**************@TK2MSFTNGP09.phx.gbl>
<#r**************@TK2MSFTNGP12.phx.gbl>
!> !In-Reply-To: <#r**************@TK2MSFTNGP12.phx.gbl>
!> !Content-Type: text/plain; charset=us-ascii; format=flowed
!> !Content-Transfer-Encoding: 7bit
!> !Message-ID: <uB*************@TK2MSFTNGP10.phx.gbl>
!> !Newsgroups: microsoft.public.dotnet.framework.aspnet
!> !NNTP-Posting-Host: 207.106.112.178
!> !Lines: 1
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet:167121
!> !X-Tomcat-NG: microsoft.public.dotnet.framework.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" <De*********@SatoriGroupInc.com> wrote in message
!> !> news:Ov**************@TK2MSFTNGP09.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!
!> !>>
!> !>
!> !>
!> !>
!> !
!> !
!>
!>
!
!

Nov 17 '05 #7
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 <De*********@SatoriGroupInc.com>
!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: <Ov**************@TK2MSFTNGP09.phx.gbl> <#r**************@TK2MSFTNGP12.phx.gbl>
<uB*************@TK2MSFTNGP10.phx.gbl> <5n**************@cpmsftngxa06.phx.gbl> <3F3A77A0.1000308
@SatoriGroupInc.com> <p#**************@cpmsftngxa06.phx.gbl>
!In-Reply-To: <p#**************@cpmsftngxa06.phx.gbl>
!Content-Type: text/plain; charset=ISO-8859-1; format=flowed
!Content-Transfer-Encoding: 8bit
!Message-ID: <#8**************@TK2MSFTNGP10.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 207.106.112.178
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167845
!X-Tomcat-NG: microsoft.public.dotnet.framework.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: <3F**************@SatoriGroupInc.com>
!> !Date: Wed, 13 Aug 2003 13:38:40 -0400
!> !From: Matthew Wieder <De*********@SatoriGroupInc.com>
!> !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]" <yh*****@online.microsoft.com>
!> !Subject: Re: Empty DataGrid Formatting
!> !References: <Ov**************@TK2MSFTNGP09.phx.gbl>
!> <#r**************@TK2MSFTNGP12.phx.gbl>
!> <uB*************@TK2MSFTNGP10.phx.gbl>
!> <5n**************@cpmsftngxa06.phx.gbl>
!> !In-Reply-To: <5n**************@cpmsftngxa06.phx.gbl>
!> !Content-Type: text/plain; charset=us-ascii; format=flowed
!> !Content-Transfer-Encoding: 7bit
!> !Newsgroups: microsoft.public.dotnet.framework.aspnet
!> !NNTP-Posting-Host: 207.106.112.178
!> !Lines: 1
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167586
!> !X-Tomcat-NG: microsoft.public.dotnet.framework.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="LightSalmon"></HeaderStyle>
!> !> </asp:DataGrid>
!> !>
!> !> 2) for row colors:
!> !> we could implement the ItemDataBound event for the datagrid.
!> !>
!> !> // event code
!> !> private void dGrid_ItemDataBound(object sender,
!> !> System.Web.UI.WebControls.DataGridItemEventArgs e) {
!> !> // only apply on item and alternating item
!> !> if (e.Item.ItemType == ListItemType.Item ||
!> !> e.Item.ItemType == ListItemType.AlternatingItem)
!> !> {
!> !> // 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.ToInt32(sVal) == 3)
!> !> {
!> !> e.Item.BackColor = 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=System.Drawing.Color.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 <De*********@SatoriGroupInc.com>
!> !> !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: <Ov**************@TK2MSFTNGP09.phx.gbl>
!> <#r**************@TK2MSFTNGP12.phx.gbl>
!> !> !In-Reply-To: <#r**************@TK2MSFTNGP12.phx.gbl>
!> !> !Content-Type: text/plain; charset=us-ascii; format=flowed
!> !> !Content-Transfer-Encoding: 7bit
!> !> !Message-ID: <uB*************@TK2MSFTNGP10.phx.gbl>
!> !> !Newsgroups: microsoft.public.dotnet.framework.aspnet
!> !> !NNTP-Posting-Host: 207.106.112.178
!> !> !Lines: 1
!> !> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!> !> !Xref: cpmsftngxa06.phx.gbl
!> microsoft.public.dotnet.framework.aspnet:167121
!> !> !X-Tomcat-NG: microsoft.public.dotnet.framework.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" <De*********@SatoriGroupInc.com> wrote in message
!> !> !> news:Ov**************@TK2MSFTNGP09.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!
!> !> !>>
!> !> !>
!> !> !>
!> !> !>
!> !> !
!> !> !
!> !>
!> !>
!> !
!> !
!>
!
!
Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
In my Win App, I have a datagrid that's bound to a dataset. When the form loads, the datagrid fills. How can I add an empty row to the end of the...
0
by: Frnak McKenney | last post by:
One of the reasons given for the Allied victory in WWI is that the Nazi armament industry invested so much effort in creating new weapons (e.g. ...
1
by: J.B | last post by:
I have a datagrid that will display different datasets, (it runs different sprocs based on a value in the querystring) but it will always return 6...
3
by: McNutt Consulting | last post by:
I'm trying to implement a datagrid with dynamically created columns. The data is coming out of a very simple XML file, and it's bound through a...
5
by: tshad | last post by:
I have been trying to figure out what the Datagrid is doing to create its formatting. I found that some of my Datagrids have a 3D type of border...
2
by: carballosa | last post by:
Hi guys, I need to use a one row datagrid in my asp.net 1.1 application. The data source will contain 1 or 0 entries. When no rows of data are...
5
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown....
1
by: Michael Calvin | last post by:
Some basic things I cannot figure out how to do with new datagrid. 1) How do I control the formatting of the column header separately from the...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.