在运行时创建动态字段 [英] Create Dynamic Fields on Run Time

查看:91
本文介绍了在运行时创建动态字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MS SQL SERVer 2012开发我的ASP.NET学期项目,我正在开发像twitter这样的社交应用程序。

我已经创建了用户发布他的用户界面和数据库通知on和i当用户预览他的所有通知时,所有通知消息都以列表样式显示,并带有删除和更新按钮。我已经使这个静态像预览一样只有最近的10个通知。



但是当用户预览他的通知页面时我想要这个。通知消息及其计数是从数据库获取并动态创建并在运行时显示在文本框/标签上,不依赖于通知它是100或10。它将创建多个文本框的数量为每个用户的通知。

I am working on a my ASP.NET Semester Project with MS SQL SERVer 2012, and i am developing an Social application like twitter.
I have made the UI and database on which user post his notification on and i when user preview his all notification all the notification messages displays in a list style with delete and update button. I have made this static like preview only recent 10 notification.

But i want that when user preview his notification page. The notification messages and their count is get from database and dynamically crate and show this on text boxes/label at run time, doesn't depend how many notification it is My be 100 or 10. It will create text boxes an many as number of notification per user.

推荐答案



使用asp .net RepeaterControl并将标签和文本框放在repeater中。你可以分配数据集到RepeaterControl。

例如:

Hi,
Use asp .net RepeaterControl and put your labels and textboxes inside repeater.You can assign the dataset to RepeaterControl.
Eg:
<asp:Repeater ID="rptCustomers" runat="server">
        <ItemTemplate>
            <tr>
                <td>
                    <asp:Label ID="lblCustomerId" runat="server" Text='<%# Eval("CustomerId") %>' />
                </td>
                <td>
                    <asp:Label ID="lblContactName" runat="server" Text='<%# Eval("ContactName") %>' />
                </td>
                <td>
                    <asp:Label ID="lblCompanyName" runat="server" Text='<%# Eval("CompanyName") %>' />
                </td>
            </tr>
        </ItemTemplate>
    </asp:Repeater>


这篇关于在运行时创建动态字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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