2014-08-28 71 views
1

我正在使用telerik rad網格。我成功導入了我選擇使用的6個字段的數據&,但是在這6個字段之後,我的radgrid將使用它們的字段名稱作爲列標題,從我的數據庫查詢中重新導入所有字段。總的來說,我的查詢調用了9個字段,所以我總共有15個列。我想要的6(加2列'編輯'&「刪除」),加上我的查詢9。
我想要的標題如下: 名稱|說明|圖像|開始日期|結束日期|主動Telerik Radgrid:意外地填充所有查詢字段的網格

取而代之,我得到這個: 名稱|說明|圖像|開始日期|結束日期|活動|電子郵件推廣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> 

任何想法如何我意外導入這些附加字段?

感謝

回答

2

AutoGenerateColumns="false"在網格的主要定義:

<telerik:RadGrid 
    ID="rgPromotions" 
    AutoGenerateColumns="false" 
    ... 
+0

這正是它。謝謝! – goalie35 2014-08-28 14:11:30