如何在listview中显示所有列 [英] How to show all columns in listview
问题描述
我有一个asp.net网络表单和listview。我想使用linq从ms sql表中获取数据。但是当我看到结果时,我看不到带有样本第一个字段(人的身份)的行。如何显示所有结果?在我的sql表中,我看到它是这样的:
id name
12 John
19 Newton
13 Andrew
13 Andrew
当我显示页面时,我只看到前两行
我的代码:
我的代码:
I have an asp.net web form and listview on it . I want to take data from ms sql table using linq . But when i see result i can't see rows with sample first field (id of person) . How can i display All results ? In my sql table i see it like this:
id name
12 John
19 Newton
13 Andrew
13 Andrew
And when i show page i see only first two rows
My code:
My code:
<asp:ListView ID="ListView2" ItemType="DocCat.Models.ReqInf" SelectMethod="GetData
DataKeyNames="ID" EnableViewState="false" runat="server" visible="true"
UpdateMethod="ListView2_UpdateItem" >
代码:
Code :
public IEnumerable
Asp.Net Web表单,实体框架
我尝试了什么:
更改行名称,更改orderby参数
Asp.Net Web Form, Entity Framework
What I have tried:
Change row names, change orderby parametr
推荐答案
您好
您可以使用eval()方法将字段分配给ListView中的参数:
Hello
You can use eval() method to to assign the field to the parameter in ListView:
in Page.aspx
Eval("Name")
列表视图中的名称参数
并使用Linq从数据库加载数据:
in Page.aspx.cs
for the Name Parameter in your ListView
and using Linq to load data from database:
in Page.aspx.cs
var q = Database_Name.Table_Name.OrderBy(c => c.ID);
ListView.datasource = q;
ListView.dataBind();
此代码将从数据库中获取数据并将Name值与Eval相关联(名称)
希望它有用
This code will fetch data from database and put "Name" values associated with "Eval("Name")"
Hope it Works
检查上一个问题 [ ^ ]。
这篇关于如何在listview中显示所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!