以编程方式选择/使用ItemTemplate或AlternatingItemTemplate

时间:2022-04-25 15:49:33

I have a ASP.NET repeater, and i want to make use of it's ItemTemplate and AlternatingItemTemplate slightly different as how they are supposed to be used. Instead of having ASP.NET to switch between the 2 for every odd/even item, i want to choose the right template in the ItemDataBound event.

我有一个ASP.NET转发器,我想利用它的ItemTemplate和AlternatingItemTemplate略有不同,因为它们应该如何使用。我想在ItemDataBound事件中选择正确的模板,而不是让ASP.NET在每个奇数/偶数项之间切换2。

Does anyone know whether this is possible?

有谁知道这是否可能?

I saw that which template is being applied, comes from which ItemType the row/item has. So if anyone knows how to manipulate that value, that would be great as well.

我看到正在应用哪个模板,来自行/项具有的ItemType。因此,如果有人知道如何操纵该值,那也会很好。

1 个解决方案

#1


1  

Turns out that this is really not possible. The only option you have here, is to write your own version that inherits from ASP.NET repeater. Then, of course, you can do/overrule whatever you like to do with your templates.

事实证明这是不可能的。您在这里唯一的选择是编写自己的继承自ASP.NET转发器的版本。然后,当然,您可以执行/否决您喜欢的模板。

#1


1  

Turns out that this is really not possible. The only option you have here, is to write your own version that inherits from ASP.NET repeater. Then, of course, you can do/overrule whatever you like to do with your templates.

事实证明这是不可能的。您在这里唯一的选择是编写自己的继承自ASP.NET转发器的版本。然后,当然,您可以执行/否决您喜欢的模板。