如何从数据库值动态创建标签 [英] How to Create labels dynamically from database value

查看:78
本文介绍了如何从数据库值动态创建标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据数据库表列值在Web表单中创建n no标签。



如果表包含5行,那么我想创建5个带文本的标签标签前面的行值和空文本框

解决方案

您好,



请尝试以下代码,'n'是表中的行值



   int  i =  0 ; i <  n; i ++)
{

Label lbl = new Label();
lbl.ID = Label + i.ToString();

Panel1.Controls.Add(lbl); // 将标签添加到面板
}


How to create n no of label in web form according to database table column value.

If table contain 5 rows then I want to create 5 labels with text of row value & empty text box ahead of label

解决方案

Hi,

Please try the following code , 'n' is the row value from your table

for (int i = 0; i < n; i++)
        {

            Label lbl = new Label();
            lbl.ID = "Label" + i.ToString();

            Panel1.Controls.Add(lbl); // add the label to a panel
        }


这篇关于如何从数据库值动态创建标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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