asp.net gridview 绑定到特定类型的更深层次属性
我的网站有一个 gridview 我将它绑定到从 powershell 接收的数据集,
该数据集中有很多不同的数据类型。
一切工作正常,但对于一个字段,我想将更深的属性绑定到边界字段!
我这样绑定它:
c#
GridViewAgentGroups.DataSource = dt;
GridViewAgentGroups.DataBind();
标记
<asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" />
<asp:BoundField HeaderText="Service" ReadOnly="True"
DataField="Identity" />
<asp:BoundField DataField="Description" HeaderText="Description"
ReadOnly="True" />
服务的绑定字段绑定到类型的数据:“Microsoft.Rtc.Rgs.Management.RgsIdentity”
它包含一个instanceID
和serviceID
属性,并且 serviceID
包含属性 fullName
!
当我像 "DataField="Identity"
一样直接绑定它时,它显示一个非常长的字符串,其中包含 fullName!
有没有办法只绑定 fullName?就像 "DataField="Identity. ServiceID.FullName”
?在 XML 中? (这不起作用:-)
my webside has a gridview
i bind it to a dataset recived from powershell
in this dataset are a lot of different data types.
everything is working fine but for one field i would like to bind a deeper property to the boundfield!
i bind it like this:
c#
GridViewAgentGroups.DataSource = dt;
GridViewAgentGroups.DataBind();
Markup
<asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" />
<asp:BoundField HeaderText="Service" ReadOnly="True"
DataField="Identity" />
<asp:BoundField DataField="Description" HeaderText="Description"
ReadOnly="True" />
the boundfield of service binds to data of type: "Microsoft.Rtc.Rgs.Management.RgsIdentity"
it contains an instanceID
and serviceID
propertyand the serviceID
contains a property fullName
!
when i bind it directly like "DataField="Identity"
it shows a very long string with the fullName included!
is there a way to only bind the fullName? like "DataField="Identity.ServiceID.FullName"
? in xml? (this does not work :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,
TemplateFields
是可能的,但它也取决于dataSource
设计。看看这个示例:标记:
隐藏代码:
Yes it is possible with
TemplateFields
but it depends upon thedataSource
design too. Have a look at this sample:Markup:
Code behind: