简体   繁体   中英

How to tweak the content in the drop down list in asp.net

我有一个下拉列,并且下拉列表包含一个值“ accidents”。现在,我想将该值读取为大写的“ Accidents”,并且网格中有很多这样的内容。一种方法是更新当前值转换为大写字母,但是由于这些值正在应用程序中使用,因此它们希望用小写字母写词。如何通过代码处理这些值。

给您的下拉列表一个CSS类(让我们说“ my-ddl”)并将其添加到您的CSS文件中。

.my-ddl { text-transform: capitalize; }

Do it from your datasource and that will depend on what kind of datasource you have

   List<X> newList = new List<X>();
   foreach(var item in origList)
   {
      newList.Add(new X {value = item.Value, 
                         text = Capitalize(item.Value)
                        });
   }

   dropdownlist.DataSource = newList;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM