【发布时间】:2011-08-05 20:16:19
【问题描述】:
我正在使用 linq-to-sql 绑定一个 radgrid,我正在使用这个绑定网格(因为我将执行 CRUD):
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) {
RadGrid1.DataSource = DbContext.SucursalClienteProveedores;
}
在我的数据库中,我有一个名为 Contact 的列,它是一个 Xml 数据类型,如下所示:
<contacto>
<nombre>Andrés Gutiérrez Hernández</nombre>
<cargo>CEO</cargo>
<telefono1>53-93-75-74</telefono1>
<telefono2>044-55-39-40-96-59</telefono2>
<email>gutierrez.andres@comprobantes.mx</email>
</contacto>
行如下所示:
FIN020938SVR |123 |FEAR3434 |霍莉莫莉| |43 |Andrés Gutiérrez HernándezCEO53-93-75-74044-55-39-40-96-59gutierrez.andres@comprobantes.mx|0 |02/08/2011 12:00:00 a.m.
我正在尝试将 GridBoundColumn 绑定到节点 telefono1,在设计器上我执行了以下操作:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
CellSpacing="0" GridLines="None" ondeletecommand="RadGrid1_DeleteCommand"
oninsertcommand="RadGrid1_InsertCommand" onitemcreated="RadGrid1_ItemCreated"
onneeddatasource="RadGrid1_NeedDataSource"
onupdatecommand="RadGrid1_UpdateCommand">
<MasterTableView DataKeyNames="RFC,IDSucursal" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
Columns>
<telerik:GridBoundColumn HeaderText="RFC" UniqueName="RFC" DataField="RFCCP">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Alias" UniqueName="Alias" DataField="NombreComercial">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Razon Social" UniqueName="razon_social" DataField="RazonSocial">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="TEL" UniqueName="Tel" DataField="Contacto.telefono1" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Email" UniqueName="Email" >
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
当然 TEL 列没有检索任何值,我可以创建一个 linq 查询并返回一个 IEnumerable 接口,但我想知道是否有一种简单的方法,
提前致谢
【问题讨论】:
标签: c# asp.net xml sql-server-2008 telerik-grid