我正在尝试在ItemDataBound中找到RadGrid的单元格。有两种telerik:RadTab,分别称为“ Sevkiyat”和“ Performans”,并且其中的单元格取决于,例如,如果Sevkiyat中的单元格值大于10,则位于Performans选项卡中,否则不是。
代码如下:
ascx:
<telerik:RadPageView ID="RadPageView3" runat="server">
<div class="row-fluid">
<div class="span12">
<div class="box">
<div class="content">
<div class="form-row row-fluid" id="Div3" runat="server">
<div class="span12 form-actions">
<div class="form-row row-fluid">
<div class="span6">
<telerik:RadGrid ID="grdPerformance" runat="server" AllowPaging="True" AutoGenerateColumns="false"
MasterTableView-CommandItemSettings-ShowRefreshButton="false" EditItemStyle-VerticalAlign="Top"
PageSize="50" Skin="Metro" Visible="true" MasterTableView-CommandItemSettings-ShowAddNewRecordButton="false" OnNeedDataSource="grdPerformance_NeedDataSource" OnDeleteCommand="grdPerformance_DeleteCommand" OnItemDataBound="grdPerformance_ItemDataBound"
AllowSorting="true" HorizontalAlign="Center" GridLines="None" ShowFooter="true" ShowHeadersWhenNoRecords="true" AllowFilteringByColumn="true">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" CommandItemDisplay="Top" Height="100%" EditMode="EditForms">
<Columns>
<telerik:GridBoundColumn HeaderText="Id" DataField="Id" UniqueName="ID" AllowFiltering="true" AutoPostBackOnFilter="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="ShipmentId" DataField="P_M_PurchasingOrder_Shipment_Id" AllowFiltering="true" AutoPostBackOnFilter="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Tekliflendirme Sorumlusu Performansi" DataField="OfferResponsiblePerformance" AllowFiltering="true" AutoPostBackOnFilter="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Satin Alma Personeli Performansi" DataField="PurchaseResponsiblePerformance" AllowFiltering="true" AutoPostBackOnFilter="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="AltYuklenici Performansi" UniqueName="SubContractorPerf" DataField="SubContractorPerformance" AllowFiltering="true" AutoPostBackOnFilter="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Uretim Muhendisi Performansi" DataField="ProductEngineerPerformance" AllowFiltering="true" AutoPostBackOnFilter="true">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
HeaderText="Delete" UniqueName="DeleteColumn" HeaderStyle-Width="50">
<ItemStyle HorizontalAlign="Left" CssClass="MyEditImageButton" />
</telerik:GridButtonColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</telerik:RadPageView>
ascx.cs
protected void grdPerformance_ItemDataBound(object sender, GridItemEventArgs e)
{
if(pmsSrv.getCalculatedPurchasingPerformance(PurchasingId) > 10)
{
//trying to find the cell-row
foreach (GridDataItem dataitem in grdPerformance.MasterTableView.Items)
{
var gdi = dataitem as GridDataItem;
if (gdi != null)
{
//do the staff
}
}
}
}
但是,grdPerformance.MasterTableView.Items计数为0,因此它甚至都没有进入for循环并进行处理。
感谢您的帮助。
谢谢。
乞
编辑:
OnPreRender代替ItemDataBound可以很好地找到RadGrid的单元,因为单元绑定已经完成。