Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Gridview right border on a per-column basis

Reply
Thread Tools

Gridview right border on a per-column basis

 
 
pickedaname
Guest
Posts: n/a
 
      06-19-2006
Hi, I am trying to figure out how to either insert a 'spacer' between columns
(which I can control width and color) or give a column/cell a border only on
the right side. Can I do this in .net 2, or would I have to use css? If so,
how do I apply the style to just the cells or columns I want? I have certain
catagories of columns grouped in the gridview and need this 'line' between
groups of columns to make it easier to read the gridview for the users.
Thanks
 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      06-20-2006
Hi,

Thank you for your post.

Based on my understanding, the question is: how to insert a 'spacer'
between columns so that certain categories of columns can be grouped. If
I've misunderstood anything, please free free to post here.

I suggest using an empty column between certain columns and set its width
or background color. For example:

<asp:TemplateField>
<HeaderStyle Width=100px BackColor="blue" />
<ItemStyle BackColor="blue" />
</asp:TemplateField>

Please note, since the GridView generated html is using table, to make the
width settings work, you may need to set a total width on the GridView tag
and set all other columns' width. Another approach may be using some spaces
to set as the empty column's HeaderText property.

Hope this helps. Please feel free to post here if anything is unclear.


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
pickedaname
Guest
Posts: n/a
 
      06-20-2006
Hi,
empty column was the 1st thing I tried. Can set color, but the width doesnt
go narrow enough to look like a cell border (like in Excel)
please help, Thanks.

"Walter Wang [MSFT]" wrote:

> Hi,
>
> Thank you for your post.
>
> Based on my understanding, the question is: how to insert a 'spacer'
> between columns so that certain categories of columns can be grouped. If
> I've misunderstood anything, please free free to post here.
>
> I suggest using an empty column between certain columns and set its width
> or background color. For example:
>
> <asp:TemplateField>
> <HeaderStyle Width=100px BackColor="blue" />
> <ItemStyle BackColor="blue" />
> </asp:TemplateField>
>
> Please note, since the GridView generated html is using table, to make the
> width settings work, you may need to set a total width on the GridView tag
> and set all other columns' width. Another approach may be using some spaces
> to set as the empty column's HeaderText property.
>
> Hope this helps. Please feel free to post here if anything is unclear.
>
>
> Regards,
> Walter Wang
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      06-20-2006
Hi,

Thank you for your update.

How about this approach:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs
e)
{
e.Row.Cells[0].Style.Add("border-right-width", "3px");
e.Row.Cells[0].Style.Add("border-right-color", "blue");
}


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
pickedaname
Guest
Posts: n/a
 
      06-20-2006
Hi Walter,
Is this referring to a css style which gets applied while the table is being
sent as html?, the "border-right-width" I am not finding in any class. How do
I apply this?

"Walter Wang [MSFT]" wrote:

> Hi,
>
> Thank you for your update.
>
> How about this approach:
>
> protected void GridView1_RowCreated(object sender, GridViewRowEventArgs
> e)
> {
> e.Row.Cells[0].Style.Add("border-right-width", "3px");
> e.Row.Cells[0].Style.Add("border-right-color", "blue");
> }
>
>
> Regards,
> Walter Wang
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
pickedaname
Guest
Posts: n/a
 
      06-20-2006

e.Row.Cells(1).Style.Add("border-right-color", "LightGray")

results in
Specified argument was out of the range of valid values.
Parameter name: index . I am assuming it is referring to the cells index.
I don't see how 1 could be out of range. I am using the pager.

"Walter Wang [MSFT]" wrote:

> Hi,
>
> Thank you for your update.
>
> How about this approach:
>
> protected void GridView1_RowCreated(object sender, GridViewRowEventArgs
> e)
> {
> e.Row.Cells[0].Style.Add("border-right-width", "3px");
> e.Row.Cells[0].Style.Add("border-right-color", "blue");
> }
>
>
> Regards,
> Walter Wang
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      06-21-2006

Hi,

Thank you for your update.

The "border-right-width" and "border-right-color" are standard CSS 2.1
attributes.

And you need to check for the row type in the RowCreated event:

If e.Row.RowType = DataControlRowType.Header Or e.Row.RowType =
DataControlRowType.DataRow Then
e.Row.Cells(1).Style.Add("border-right-width", "3px")
e.Row.Cells(1).Style.Add("border-right-color", "blue")
End If

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
pickedaname
Guest
Posts: n/a
 
      06-22-2006
Hi Walter,
I did as you said. No exceptions but border is not being applied to the html
table upon output. I tried it also in the render event and nothing there
either. I am not currently applying any css files to the site.
Any other suggestions?
Thanks

"Walter Wang [MSFT]" wrote:

>
> Hi,
>
> Thank you for your update.
>
> The "border-right-width" and "border-right-color" are standard CSS 2.1
> attributes.
>
> And you need to check for the row type in the RowCreated event:
>
> If e.Row.RowType = DataControlRowType.Header Or e.Row.RowType =
> DataControlRowType.DataRow Then
> e.Row.Cells(1).Style.Add("border-right-width", "3px")
> e.Row.Cells(1).Style.Add("border-right-color", "blue")
> End If
>
> Hope this helps. Please feel free to post here if anything is unclear.
>
> Regards,
> Walter Wang
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      06-22-2006
Hi,

Thank you for your update.

Looks like I forgot to set the style to 'solid':

Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.Header Or e.Row.RowType =
DataControlRowType.DataRow Then
e.Row.Cells(1).Style.Add("border-right-width", "5px")
e.Row.Cells(1).Style.Add("border-right-color", "blue")
e.Row.Cells(1).Style.Add("border-right-style", "solid")
End If
End Sub



Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
pickedaname
Guest
Posts: n/a
 
      06-22-2006
Thank you Walter, it worked like a champ.

"Walter Wang [MSFT]" wrote:

> Hi,
>
> Thank you for your update.
>
> Looks like I forgot to set the style to 'solid':
>
> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
> If e.Row.RowType = DataControlRowType.Header Or e.Row.RowType =
> DataControlRowType.DataRow Then
> e.Row.Cells(1).Style.Add("border-right-width", "5px")
> e.Row.Cells(1).Style.Add("border-right-color", "blue")
> e.Row.Cells(1).Style.Add("border-right-style", "solid")
> End If
> End Sub
>
>
>
> Regards,
> Walter Wang
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
splitting an XML file on the basis on basis of XML tags bijeshn@gmail.com Python 14 04-08-2008 04:26 AM
border-color: #003366; border-width: 2px; =?UTF-8?B?TWFydGluIFDDtnBwaW5n?= HTML 64 07-30-2006 04:01 PM
Drop Down List Border Width vs Text Box Border Width Coder ASP .Net 1 06-24-2006 01:27 PM
row bottom border in inner table not matching up with row border in outer table phl HTML 1 06-08-2006 03:43 PM
Datagrid Border showing when I say no border tshad ASP .Net 0 01-31-2005 05:40 PM



Advertisments