在asp.net gridview中创建行标题

在asp.net gridview中创建行标题,asp.net,gridview,Asp.net,Gridview,我在asp.net网格视图中有一个奇怪的要求。如下图所示,是否可以同时具有列标题和行标题 如果是,我还有一个问题 1.)我想根据失败数量和批次数量自动计算失败百分比行中的失败百分比,就像我们在excel中所做的那样 非常感谢您的帮助,提前感谢 我想你有一个集合,我们称之为origCollection,它以某种方式包含数据。我通常做的是将origCollection转换为另一个,我们称之为newCollection,它具有您想要的形式。您需要此类来映射单行: Class myRow {

我在asp.net网格视图中有一个奇怪的要求。如下图所示,是否可以同时具有列标题和行标题

如果是,我还有一个问题

1.)我想根据失败数量批次数量自动计算失败百分比行中的失败百分比,就像我们在excel中所做的那样


非常感谢您的帮助,提前感谢

我想你有一个集合,我们称之为
origCollection
,它以某种方式包含数据。我通常做的是将
origCollection
转换为另一个,我们称之为
newCollection
,它具有您想要的形式。您需要此类来映射单行:

Class myRow {
    public string title {get; set;} //Failure %, Failed Quantity, ...
    public string test1{get; set;}
    public string test2{get; set;}
    public string test3{get; set;}
    public string test4{get; set;}
    public string test5{get; set;}
}
然后,在数据绑定之前,您可以通过以下方式创建
newCollection

//create newCollection
var newCollection = new List<myRow>();

//for each row you wnt to put in newCollection:
newCollection.Add(new myRow(){
   title = "Failure %",
   test1 = // calculate value from origCollection,
   test2 = // calculate value from origCollection,
   test3 = // calculate value from origCollection,
   test4 = // calculate value from origCollection,
   test5 = // calculate value from origCollection
} );

这是我通常的做法,我希望这有助于

我想你有一个集合,让我们称之为
origCollection
,它以某种方式包含数据。我通常做的是将
origCollection
转换为另一个,我们称之为
newCollection
,它具有您想要的形式。您需要此类来映射单行:

Class myRow {
    public string title {get; set;} //Failure %, Failed Quantity, ...
    public string test1{get; set;}
    public string test2{get; set;}
    public string test3{get; set;}
    public string test4{get; set;}
    public string test5{get; set;}
}
然后,在数据绑定之前,您可以通过以下方式创建
newCollection

//create newCollection
var newCollection = new List<myRow>();

//for each row you wnt to put in newCollection:
newCollection.Add(new myRow(){
   title = "Failure %",
   test1 = // calculate value from origCollection,
   test2 = // calculate value from origCollection,
   test3 = // calculate value from origCollection,
   test4 = // calculate value from origCollection,
   test5 = // calculate value from origCollection
} );

这是我通常的做法,我希望这有助于

我想你有一个集合,让我们称之为
origCollection
,它以某种方式包含数据。我通常做的是将
origCollection
转换为另一个,我们称之为
newCollection
,它具有您想要的形式。您需要此类来映射单行:

Class myRow {
    public string title {get; set;} //Failure %, Failed Quantity, ...
    public string test1{get; set;}
    public string test2{get; set;}
    public string test3{get; set;}
    public string test4{get; set;}
    public string test5{get; set;}
}
然后,在数据绑定之前,您可以通过以下方式创建
newCollection

//create newCollection
var newCollection = new List<myRow>();

//for each row you wnt to put in newCollection:
newCollection.Add(new myRow(){
   title = "Failure %",
   test1 = // calculate value from origCollection,
   test2 = // calculate value from origCollection,
   test3 = // calculate value from origCollection,
   test4 = // calculate value from origCollection,
   test5 = // calculate value from origCollection
} );

这是我通常的做法,我希望这有助于

我想你有一个集合,让我们称之为
origCollection
,它以某种方式包含数据。我通常做的是将
origCollection
转换为另一个,我们称之为
newCollection
,它具有您想要的形式。您需要此类来映射单行:

Class myRow {
    public string title {get; set;} //Failure %, Failed Quantity, ...
    public string test1{get; set;}
    public string test2{get; set;}
    public string test3{get; set;}
    public string test4{get; set;}
    public string test5{get; set;}
}
然后,在数据绑定之前,您可以通过以下方式创建
newCollection

//create newCollection
var newCollection = new List<myRow>();

//for each row you wnt to put in newCollection:
newCollection.Add(new myRow(){
   title = "Failure %",
   test1 = // calculate value from origCollection,
   test2 = // calculate value from origCollection,
   test3 = // calculate value from origCollection,
   test4 = // calculate value from origCollection,
   test5 = // calculate value from origCollection
} );

这是我通常的做法,我希望这能有所帮助

谢谢@balanza。这确实有帮助,但如果行数增加,解决方案的长度会增加,这会对面向对象的特性提出问题。是否有网格视图属性或任何其他控件可以满足我的要求?@user2470766对于后处理单元格值,您可以始终使用
GridView.RowDataBound
event。但对于处理数据表的结构,我只能建议使用中间转换集合,如上所述。“如果行数增加,解决方案的长度会增加,这会对面向对象的特性提出问题”,这是什么意思?在上述解决方案中,我们必须为每一行添加一个新集合。如果我的数据有一百行,那么对于每一行数据,我们必须编写newCollection.Add(new myRow()代码的另一部分。你不能用for循环管理它吗?现在数据绑定如何?谢谢@balanza。它确实有帮助,但如果行数增加,解决方案的长度会增加,这会对面向对象的特性提出问题。难道没有网格视图属性或任何其他控件可以满足我的要求吗e?@user2470766对于后处理单元格值,您可以始终使用
GridView.RowDataBound
event。但是对于处理数据表的结构,我只能建议使用中间转换集合,如上所述。您对它的意思是什么“如果行数增加,则解决方案的长度会增加,这会对面向对象的功能提出问题”?在上述解决方案中,我们必须为每行放入一个新集合。如果我的数据有数百行,则我们必须为每行数据写入新集合。添加(new myRow()代码的另一部分。你不能用for循环管理它吗?现在数据绑定如何?谢谢@balanza。它确实有帮助,但如果行数增加,解决方案的长度会增加,这会对面向对象的特性提出问题。难道没有网格视图属性或任何其他控件可以满足我的要求吗e?@user2470766对于后处理单元格值,您可以始终使用
GridView.RowDataBound
event。但是对于处理数据表的结构,我只能建议使用中间转换集合,如上所述。您对如果行数增加,则解决方案的长度会增加,这会对“面向对象”的功能提出问题。在上述解决方案中,我们必须为每行放入一个新集合。如果我的数据有数百行,则我们必须为每行数据写入新集合。添加(new myRow()代码的另一部分。你不能用for循环管理它吗?现在数据绑定如何?谢谢@balanza。它确实有帮助,但如果行数增加,解决方案的长度会增加,这会对面向对象的特性提出问题。难道没有网格视图属性或任何其他控件可以满足我的要求吗e?@user2470766对于后处理单元格值,您可以始终使用
GridView.RowDataBound
event。但是对于处理数据表的结构,我只能建议使用中间转换集合,如上所述。您对如果行数增加,则解决方案的长度会增加,这会对“面向对象”的功能提出问题。在上述解决方案中,我们必须为每行放入一个新集合。如果我的数据有数百行,则我们必须为每行数据写入新集合。添加(new myRow()又是代码的一部分。你不能用for循环管理它吗?数据绑定现在怎么样?