2012-02-03 172 views
0

如何從radgrid下面訪問RadAsyncUpload的telerik控件。我在aspx頁面中有下面的代碼。在頁面加載過程中,我需要在某些情況下禁用telerik控件。如何從下面的代碼禁用telerik控件?如何從telerik radgrid訪問telerik控件

<telerik:RadGrid ID="RadGrid1" 
       runat="server" 
       AutoGenerateColumns="False" 
       GridLines="None" 
       Skin="Black" 
       Width="750px" 
       Height="320px"> 
    <PagerStyle Mode="NextPrevAndNumeric" /> 
    <SelectedItemStyle CssClass="SelectedItem"/>       
    <MasterTableView EditMode="InPlace" 
        CommandItemDisplay="None" 
        AllowFilteringByColumn="True" 
        DataKeyNames="FileName"> 
    <Columns> 
     <telerik:GridBoundColumn ReadOnly="true" 
           DataField="FileName" 
           UniqueName="FileName" 
           AllowFiltering="false" 
           ItemStyle-Width="200px" 
           HeaderStyle-Width="205px" 
           HeaderStyle-HorizontalAlign="Left" 
           ItemStyle-HorizontalAlign="Left" 
           ItemStyle-BackColor="Gray"> 
     </telerik:GridBoundColumn> 
     <telerik:GridTemplateColumn UniqueName="FilePath" 
            Visible="true" 
            ItemStyle-Width="310px" 
            HeaderStyle-Width="355px" 
            HeaderStyle-HorizontalAlign="Left" 
            ItemStyle-HorizontalAlign="Left" 
            AllowFiltering="false" 
            ItemStyle-BackColor="Gray"> 
     <ItemTemplate>           
      <telerik:RadAsyncUpload runat="server" ID="RadUpload1"> 
      </telerik:RadAsyncUpload> 
     </ItemTemplate> 
     </telerik:GridTemplateColumn> 
    </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 
+0

請詳細提供您的問題。你想禁用RadAsyncUpload控制或其他? – 2012-02-03 05:37:03

+0

只有我已禁用RadAsyncUpload控制頁面加載期間執行某些條件.. – 2012-02-03 06:17:31

回答

0

您將在RadGrid的DataBinding/DataBound Item事件期間禁用RadAsyncUpload控件。

DataBinding/DataBound是事件當服務器控件綁定到數據源時發生。 (繼承自Control。)

當你綁定一個RadGrid控件。爲前。

 protected void Page_Load(object sender,System.EventArgs e) 
     { 
      if(!IsPostBack) 
      { 
// Here I creates temporary datatable.. 
// you can generate dynamic DataTable from SQL query to fill DataSet/DataTable. 
// Here I created temp DataTable for Binding RadGrid grid control.. 
      DataTable dt = new DataTable("temp");   

      RadGrid.DataSource= dt; 
      RadGrid.DataBind(); 
      // It will event fired When you binding data source. 
      // If You have to added "RadGrid_ItemDataBound" Item bound event to the <RADGRID >... control. 
      } 
     } 
      protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e) 
      { 
       if (e.Item is GridDataItem) 
       { 
        RadAsyncUpload asyncUpload = (RadAsyncUpload) e.Item.FindControl("RadAsyncUploadControlID");  
        bool blUploadControlHide=true; 
        if(asyncUpload !=null) 
        { 
        if(blUploadControlHide) 
        { 
         asyncUpload.Enabled = false; 
         //If you can hide then write asyncUpload.Visible = false; 
        } 
        else 
        { 
         asyncUpload.Enabled = true; 
        } 
        }  
       } 
      } 

參考Radgrid Events

感謝

+0

...我沒有在radgrid events..can你提供sloution – 2012-02-03 07:01:06

+0

Thanq..on condtion此事件將觸發...請幫助我是新的asp.net ... – 2012-02-03 10:12:59

+0

@ user1177921當RADGrid控件綁定的項目將被解僱..你可以通過放置斷點來檢查。 – 2012-02-03 10:49:37

0

你可以掛接到radgrid控件的ItemDataBound事件,然後找到控制,可以通過這個鏈接。 Telerik RadGrid - databound Events.

SomeGrid_ItemDataBound(object sender, GridItemEventArgs e) 
{ 
if (e.Item is GridDataItem) 
{ 
RadAsyncUpload objUpload = (RadAsyncUpload) e.Item.FindControl("RadUpload1"); 

if(opbjUpload !=null) 
{ 
    // do some thing with Upload Obj. 
} 

} 
} 
+0

thanq ...如何禁用RadAsyncUpload控制條件 – 2012-02-03 07:10:45

+0

在這種情況下,這個事件將觸發...我是新的asp.net ....請幫我 – 2012-02-03 10:14:21

+0

@ user1177921你需要綁定在itemDataBound事件 – 2012-02-03 10:18:05