如何让DropDownList控件显示粗体ASP.NET一些项目 [英] How to make a DropDownList control display some items in bold ASP.NET

查看:159
本文介绍了如何让DropDownList控件显示粗体ASP.NET一些项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与在ASP.Net自定义DropDownList控件,并有许多人请求以粗体字体显示在列表中的某些项目(注 - 从CompositeDataBoundControl控制继承因此它可以在数据绑定...不是下拉框)。该控件绑定到一个表,有名为IsUsed表中的列 - 如果它被设置为true,在列表中的相应项目应呈现大胆。 (这里应注意的是,这仅会被在FireFox观看。)

I'm working with a custom DropDownList control in ASP.Net and there's been a request to display certain items in the list with a bold typeface (NOTE - the control inherits from CompositeDataBoundControl so it can be data bound... not DropDownListBox). The control is bound to a table and there's a column in the table named IsUsed - if this is set to true, the corresponding item in the list should be rendered bold. (It should be noted here that this will only ever be viewed in FireFox.)

我的经验是所有中间\后端层所以presentation层是很新的我 - 能有人点我在正确的方向?我最初的想法是,在自定义控件的地方我将有机会获得所有的数据源,我可以循环等,但我不知道这是可能的......还有的RenderContents,我可以重写返回的行......看起来很有趣!

My experience is all in the middle \ backend tiers so the presentation layer is very new to me - can someone point me in the right direction? My initial thought was that somewhere in the custom control I would have access to all the rows that are returned from the data source which I could cycle through etc but I'm not sure if that's possible... There's also RenderContents which I can override... looks interesting!

推荐答案

好,我想我已经回答了我的问题,但它似乎并不很优雅。

OK I think I've answered my own question but it doesn't seem very elegant.

我可以写一个新的存储过程返回我需要将返回标识和说明列表中显示的数据。然而,描述将是加TRUE或FALSE(在表中根据标志IsUsed)的描述。然后,在我的RenderContents可以拆分描述字符串,解析布尔并添加一个样式属性使文本加粗,如果布尔是真实的......

I can write a new stored proc to return the data I need to display in the list that will return ID and DESCRIPTION. However, description will be the description plus TRUE or FALSE (depending on the flag IsUsed in the table). Then in RenderContents I can split the description string, parse the bool and add a style attribute making the text bold if the bool is true...

这篇关于如何让DropDownList控件显示粗体ASP.NET一些项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆