label根据数据库值更改字体 [英] label Font Change According to database Values

查看:58
本文介绍了label根据数据库值更改字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有12个标签

在asp.net页面上有所有月份的文本



我必须从中检索数据Sql

返回三个月或更多月的值



根据数据库值<

的要求

页面中的标签必须大胆..



例如:如果Datbase值返回月份名称Jan,Feb和Oct
那么相应的标签有文字1月,2月,10月必须

变为粗体......或突出显示...和其他标签保持平常。



这是我试过的东西

 Dim sd as New SqlDataAdapter(从表中选择月份,con)
Dim dt as new Datatable
sd.Fill(dt)
我的整数= 0到dt.rows.count -1
如果dt.rows(i).Item(Months)='Jan'
-------应用css到label1
结束如果
-------类似添加了If条件并应用了css

下一步



解决方案

问题是什么?



这听起来像服务器端实现。不需要单独的事件,访问数据库时都可以处理所有事件。返回数据后,根据数据将所需标签的样式设置为粗体。简单的是只更改标签的CssClass。



试用!


您好

这很简单

而不是创建标签动态创建它们并相应地更改文本并将其显示在页面上



如果您有任何样式要求,请使用CSS来实现它。

I have a 12 Labels
In asp.net page having texts Of all the Months

I have to retrieve the Data from Sql
which returns three or more month Values

The requirement is that
according to the DataBase Values
the Labels in the page must get Bold..

For ex : If Datbase values return months name Jan ,Feb and Oct
then Accordingly the label having text Jan,Feb,Oct must
get bold..or highlighted... and other labels remain as usual.

here is what i tried

Dim sd as New SqlDataAdapter("Select Months from table",con)
Dim dt as new Datatable
sd.Fill(dt)
For i as Integer =0 to dt.rows.count -1
    If  dt.rows(i).Item("Months") = 'Jan'
           -------Applied css to label1
    End If
    -------similary added the If Condition and applied the css

Next


.

解决方案

And what is the issue?

It all sounds like server side implementation. No separate event required, all can be handled when you access the database. Once the data is returned, based on the data just set the style of needed label as bold. Simple would be to just change the CssClass for the label.

Try out!


Hi
This is pretty simple
rather than creating lables create them dynamically and change the text accordingly and display it on the page

And If you have any style requirements use CSS to achieve it.


这篇关于label根据数据库值更改字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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