asp.net中的绑定网格 [英] binding grid in asp.net

查看:80
本文介绍了asp.net中的绑定网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gridview中,我将数据库中的基准绑定到标签中...在tat网格中,我必须添加多个行号,这些行应仅包含文本框,因此tat我可以在网格中输入一些值...

我不应该使用页脚模板....因此,现有行应显示在标签中,并且我不应该有任何机会编辑网格中的现有数据....唯一的事情是我需要插入"n"号应该只包含文本框而不包含标签的行的行...有人可以建议我一些解决方案吗????

In a gridview, i binded the datum from database in labels...In tat grid, i have to add multiple no.of rows which should contain only textbox , so tat i can enter some values in the grid...

I should not use footer template....So Existing rows should be displayed in labels and i should not get any chances of editing the existing datas in the grid....only thing is i need to insert ''n'' number of rows which should contain only textbox not the labels...can anyone suggest me some solution for this????

推荐答案

您可以在ItemTemplate.

这是家庭容易做的事.

You can use Labels inside the EditTemplate and ItemTemplate.

This is family easy to do.

<asp:TemplateField HeaderText="Column1">
<EditItemTemplate>
<asp:Label ID="1" runat="server" Text='<%# Bind("columntext") %>'> </asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("columntext") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>



上面的代码示例应该可以帮助您.



The above code sample should help you out.


还可以使用从db层到业务层的数据.然后根据以下内容将数据源绑定到..

下面的代码bizLyer.Select()用于从db检索数据.
然后将数据绑定到网格.

also u use get the data from db layer through business layer. then bind the datasource to based on below..

below code bizLyer.Select() is used for retrieve the data from db.
then we will bind the data to grid.

gvData.DataSource = bizLayer.Select();
gvData.DataBind();



绑定网格 [ ^ ]


这篇关于asp.net中的绑定网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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