在网格控件中显示记录(asp.net / vb.net)
我是 .net 开发世界的新手。
我想在我的 asp.net 页面上显示一组记录。
在网格控件(gridview、repeater 等)上,我想显示销售人员及其代表的客户的列表。
这就是它在我的 asp 页面上的样子:
Employee ID: 123456
Name: John
Last Name: Smith
Email: [email protected]
Phone: 201-123-4567
Client - 1
ClientID: 11111111
Client Name: XYZ Company
Client Contact: John Q Public
Client Phone: 201-222-3333
Client - 2
ClientID: 2222222
Client Name: Widget Company
Client Contact: George Williams
Client Phone: 201-333-4444
Client - 3
ClientID: 3333333
Client Name: Acme Products
Client Contact: Steve Mason
Client Phone: 201-444-3333
我的 sql 查询类似于:
Select sales.firstname, sales.lastname, sales.email, sales.phone sales.clientid from sales
select client.id, client.name, client.contact, client.phone from client, where sales.clientid = sales.clientid
代码将为所有销售记录循环
我的语法将如何构造?
I am a newbie to the .net developing world.
I want to display a set of records on my asp.net page.
On a grid control (gridview, repeater etc), I want to display the list of sales people and the clients that they represent.
This is how it needs to look on my asp page:
Employee ID: 123456
Name: John
Last Name: Smith
Email: [email protected]
Phone: 201-123-4567
Client - 1
ClientID: 11111111
Client Name: XYZ Company
Client Contact: John Q Public
Client Phone: 201-222-3333
Client - 2
ClientID: 2222222
Client Name: Widget Company
Client Contact: George Williams
Client Phone: 201-333-4444
Client - 3
ClientID: 3333333
Client Name: Acme Products
Client Contact: Steve Mason
Client Phone: 201-444-3333
My sql query is something like:
Select sales.firstname, sales.lastname, sales.email, sales.phone sales.clientid from sales
select client.id, client.name, client.contact, client.phone from client, where sales.clientid = sales.clientid
The code would loop for all sales records
How would my syntax be structured?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下示例应该对您有所帮助。
http://www.java2s.com/Tutorial/ASP.NET /0380__数据绑定/DataBindingtoGridViewC.htm
http://msdn.microsoft.com/en-us/library/aa479342.aspx
不过,您需要相应地更改查询。
Following examples should help you.
http://www.java2s.com/Tutorial/ASP.NET/0380__Data-Binding/DataBindingtoGridViewC.htm
http://msdn.microsoft.com/en-us/library/aa479342.aspx
you'll need to change the query accordingly though.
您需要处理
GridView
的RowDataBound
事件。在此处理程序中,您必须获取Repeater
控件的引用并绑定关联员工 ID 的客户端表的dataSource
。You need to handle the
RowDataBound
event ofGridView
. In this handler, you have to obtain the reference ofRepeater
control and bind thedataSource
of client table for associated employee id.