Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of dynamic column change of Repeater Control

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail the example analysis of dynamic column changes in Repeater controls. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Refactoring begins:

First of all, delete these five variables, because they are no longer needed during the refactoring process.

The copy code is as follows:

/ / declare five variables that will be used to store the number of each part in those five months

Decimal c1, c2, c3, c4, c5

The next thing to change is to declare a constant, which is used in many places:

The copy code is as follows:

Const int dynamicColumns = 5

Put the following sentence in the program

The copy code is as follows:

ObjPrintLog.Months = 5; / / for the last 5 consecutive months

Change to:

The copy code is as follows:

ObjPrintLog.Months = dynamicColumns

That is, use constant variables to replace the "5" of the old code.

Next, let's ReFactor the code for the Header of the Repwater control. For comparison, Insus.NET references the corresponding image from the previous article here:

Refactoring is as follows:

The copy code is as follows:

Protected void RepeaterLFMS_ItemDataBound (object sender, RepeaterItemEventArgs e)

{

If (e.Item.ItemType = = ListItemType.Header)

{

If (e.Item.FindControl ("LabelH0")! = null

& & e.Item.FindControl ("LabelH1")! = null

& & e.Item.FindControl ("LabelH2")! = null

& & e.Item.FindControl ("LabelH3")! = null

& & e.Item.FindControl ("LabelH4")! = null

& e.Item.FindControl ("LabelH5")! = null)

{

For (int I = 0; I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report