By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

Empty DataGrid Formatting

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.