我正在使用telerik rad网格。我成功导入数据&我选择使用的6个字段,但是在这6个字段之后,我的radgrid正在重新导入我的数据库查询中的所有字段,使用它们的字段名称作为列标题。总的来说,我的查询调用了9个字段,所以我总共有15列。我想要的6个(加上2个添加' l列为#34;编辑"&"删除"),加上我查询中的9个。
我想要的标题如下:
姓名|说明|图片|开始日期|结束日期|有效
相反,我明白了: 姓名|说明|图片|开始日期|结束日期|有效|电子邮件促销ID |促销标题|促销说明|图像名称|开始日期|结束日期|深层链接ID |有效|更新用户名
这是我的radgrid:
<telerik:RadGrid
ID="rgPromotions"
runat="server"
AllowPaging="true"
AllowSorting="true"
autopostback="false"
OnItemDataBound="rgPromotions_ItemDataBound"
OnNeedDataSource="rgPromotions_NeedDataSource"
Skin="Office2007">
<MasterTableView DataKeyNames="EmailPromotionId" Width="100%" TableLayout="Fixed" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="True" >
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px" ></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" >
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="PromotionTitle" HeaderText="Name" SortExpression="PromotionTitle" HeaderStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" ReadOnly="true" />
<telerik:GridBoundColumn DataField="PromotionDescription" HeaderText="Description" SortExpression="PromotionDescription" HeaderStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" ReadOnly="true" />
<telerik:GridBoundColumn DataField="ImageName" HeaderText="Image" SortExpression="ImageName" HeaderStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" ReadOnly="true" />
<telerik:GridDateTimeColumn DataField="StartDate" DataType="System.DateTime" FilterControlAltText="Filter Start Date column" HeaderText="Start Date" PickerType="DatePicker" DataFormatString="{0:d}" ReadOnly="true"/>
<telerik:GridDateTimeColumn DataField="EndDate" DataType="System.DateTime" FilterControlAltText="Filter End Date column" HeaderText="End Date" PickerType="DatePicker" DataFormatString="{0:d}" ReadOnly="true"/>
<telerik:GridBoundColumn DataField="Active" HeaderText="Active" SortExpression="Active" HeaderStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Center" ReadOnly="true"/>
<telerik:GridTemplateColumn DataField="EmailPromotionId" HeaderText="" ColumnGroupName="Edit" AllowFiltering="false" UniqueName="EmailPromotionIdEdit">
<ItemTemplate>
<asp:LinkButton ID="btnEdit" runat="server" Text="Edit" OnClick="btnEmailPromotionEdit_Click" CommandName="EmailPromotionId" CommandArgument='<%#Eval("EmailPromotionId") %>'></asp:LinkButton><br />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="EmailPromotionId" HeaderText="" ColumnGroupName="Edit" AllowFiltering="false" UniqueName="EmailPromotionIdEdit">
<ItemTemplate>
<asp:LinkButton ID="btnDelete" runat="server" Text="Delete" OnClick="btnEmailPromotionDelete_Click" CommandName="EmailPromotionId" CommandArgument='<%#Eval("EmailPromotionId") %>'></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
知道我是如何意外导入这些额外字段的吗?
由于
答案 0 :(得分:2)
在网格的主要定义中设置AutoGenerateColumns="false"
:
<telerik:RadGrid
ID="rgPromotions"
AutoGenerateColumns="false"
...