This is a migrated thread and some comments may be shown as answers.

[Solved] GridView InsertCommand cant get upload file control

2 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammad
Top achievements
Rank 1
Mohammad asked on 15 Apr 2013, 05:29 AM
Dear support , 
I have grid view with , and i need to access the upload file control in insertCommand and editCommand event. 
i got cant convert System.Web.UI to Telerik.Web.UI.UploadControl when i try to get the control
here is my grid and the event 

server Code.. 

protected void MasterRadGrid_InsertCommand(object source, GridCommandEventArgs e)
       {
           try
           {
               Telerik.Web.UI.UploadedFile attachment = e.Item.FindControl("txtUpdateTaskCompletion2") as Telerik.Web.UI.UploadedFile;

.aspx code
<telerik:RadGrid CssClass="GridAlign" ID="MasterRadGrid" runat="server" ShowStatusBar="true"
                        AutoGenerateColumns="False" PageSize="3" AllowSorting="True" AllowMultiRowSelection="False"
                        AllowPaging="True" GridLines="None" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
                        AllowAutomaticUpdates="True" OnInsertCommand="MasterRadGrid_InsertCommand" OnDetailTableDataBind="MasterRadGrid_DetailTableDataBind"
                        OnNeedDataSource="MasterRadGrid_NeedDataSource" OnUpdateCommand="MasterRadGrid_UpdateCommand"
                        Skin="Metro" OnDeleteCommand="MasterRadGrid_DeleteCommand">
                        <PagerStyle Mode="NumericPages"></PagerStyle>
                        <MasterTableView DataKeyNames="CommentID" AllowMultiColumnSorting="True" Width="100%"
                            CommandItemDisplay="Top" Name="MainComment">
                            <CommandItemStyle CssClass="GridAlign" />
                            <NoRecordsTemplate>
                                No Records to Display
                            </NoRecordsTemplate>
                            <HeaderStyle CssClass="InnerHeaderStyle" />
 
<EditFormSettings EditFormType="Template">
                                <FormTemplate>
                                    <div id="content">
                                        <table>
                                            
                                            <tr>
                                                <td style="width: 20%; padding-right: 10px">
                                                    <asp:Label ID="lblAttachments" runat="server" Text="<%$Resources:TMS.UI,TM_AddNewTask_lblTaskAttachmentTitle%>" />
                                                </td>
                                                <td colspan="3" style="width: 65%">
                                                    <telerik:RadUpload ControlObjectsVisibility="RemoveButtons,AddButton" ID="rpTaskAttachments" runat="server"
                                                        Localization-Add="<%$Resources:TMS.UI,TM_AddNewTask_btnAddAttachment%>"
                                                        Localization-Remove="<%$Resources:TMS.UI,TM_AddNewTask_btnRemoveAttachment%>"
                                                        Localization-Select="<%$Resources:TMS.UI,TM_AddNewTask_btnSelectAttachment%>"
                                                        OnClientAdded="AddNewFields" Width="500px">
                                                    </telerik:RadUpload>
                                                </td>
                                            </tr>
                                        </table>


if you need the full code for the grid or the code behind please tell .. 

Thanks





2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 15 Apr 2013, 05:40 AM
HI,

Try the following.
C#;
void RadGrid5_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
       {
           GridEditFormItem item = (GridEditFormItem)e.Item;
           RadUpload upload = (RadUpload)item.FindControl("RadUpload1");
       }
   }
      void RadGrid5_InsertCommand(object sender, GridCommandEventArgs e)
   {
       GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item;
       RadUpload upload = (RadUpload)item.FindControl("RadUpload1");
   }

Thanks,
Shinu
0
Mohammad
Top achievements
Rank 1
answered on 15 Apr 2013, 06:12 AM
Thx man ,, this fix the issue ,, 
Tags
Grid
Asked by
Mohammad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mohammad
Top achievements
Rank 1
Share this question
or