向 Gridview 添加行分隔符

发布于 2024-07-25 23:03:45 字数 765 浏览 1 评论 0原文

我对 ASP.NET 和 SQL 比较陌生,所以我问的问题对某些人来说可能是一个简单的问题,但对我来说不是。 我拥有的是一个网格视图,我试图用它来填充垒球击球统计数据。 在其中,我将年度统计数据堆叠在其最底部的职业生涯总计之上。 我通过对两组数据(按年份和职业生涯总计)执行半简单的 UNION 语句来完成此任务。

我最终想要的是年度总数和职业生涯总数之间有一条分界线。 对于那些熟悉棒球卡的人来说……这就是我想要的外观。 像这样的东西:

SEASON AB RH 2B 3B HR RBI BB KE SAC SLG AVG 2009 63 16 29 3 4 2 19 0 0 0 4 .730 .460


职业生涯总计 63 16 29 3 4 2 19 0 0 0 4 .730 .460

似乎当我尝试在底行添加单行边框时 (其中职业总数为)

RowCount1 = GridView1.Rows.Count - 1 GridView1.Columns.Item(RowCount1).ItemStyle.BorderStyle = BorderStyle.Solid GridView1.Rows.Item(RowCount1).BorderStyle = BorderStyle.Solid

我在职业生涯总计(最后一条记录)周围得到一个框,而不是两组数据之间的单行。 我在网上寻找如何实现这一点,但空手而归。 也许这是一个很简单的问题,大多数人都不愿意发布这个问题,但对我来说,这是一个谜。

您能提供的任何帮助将不胜感激!

I’m relatively new to ASP.NET and SQL, so what I’m asking maybe a simple question for some, but not for me. What I have is a Grid View that I’m trying to populate softball hitting statistics with. In it I’ve stacked statistics yearly statistics on top of career totals at the very bottom of it. I’ve accomplished this by doing a semi-simple UNION statement with both sets of data (by year and career totals).

What I’m ultimately looking for is there to be a dividing line between the annual totals and career totals. For those of you who are familiar with baseball cards… that is the look I’m going for. Something like this:

SEASON AB R H 2B 3B HR RBI BB K E SAC SLG AVG
2009 63 16 29 3 4 2 19 0 0 0 4 .730 .460


Career Totals 63 16 29 3 4 2 19 0 0 0 4 .730 .460

It seems that when I try to add a single line border to the bottom row (where the career totals are)

RowCount1 = GridView1.Rows.Count - 1
GridView1.Columns.Item(RowCount1).ItemStyle.BorderStyle = BorderStyle.Solid
GridView1.Rows.Item(RowCount1).BorderStyle = BorderStyle.Solid

I get a box around the career totals (last record) as opposed to a single line between the two sets of data. I’ve looked online as to how to accomplish this, but have come up empty handed. Perhaps this is such an easy question that most people don’t care to post this, but for me it’s been a mystery.

Any help you can give would be completely appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不奢求什么 2024-08-01 23:03:45

步骤 1 是定义一个 CSS 类,例如:

<style type="text/css">
   .sectionBorder
   {
      border-bottom: solid 1px black;         
   }
</style>

步骤 2 是在 RowDataBound 或 RowCreated 中添加逻辑,例如:

   if(e.Row.RowIndex == 2)  // whatever your criteria is.
        e.Row.CssClass = "sectionBorder";

Step 1 is to define a CSS Class, like:

<style type="text/css">
   .sectionBorder
   {
      border-bottom: solid 1px black;         
   }
</style>

Step 2 is to have your logic in RowDataBound or RowCreated like:

   if(e.Row.RowIndex == 2)  // whatever your criteria is.
        e.Row.CssClass = "sectionBorder";
很糊涂小朋友 2024-08-01 23:03:45

它工作得很好,而且你不需要后面的代码

 <RowStyle CssClass="SearchResultGridRowStyle" />

 .SearchResultGridRowStyle {   
    background-position:bottom;    
    background-image:url(../images/managed_hosting_middle_line.jpg);
    background-repeat:no-repeat; 
}

it works fine as well and u don't need code behind

 <RowStyle CssClass="SearchResultGridRowStyle" />

 .SearchResultGridRowStyle {   
    background-position:bottom;    
    background-image:url(../images/managed_hosting_middle_line.jpg);
    background-repeat:no-repeat; 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文