I'm having problems addressing my fileupload.
My structure looks like this:
When I use FileUploads in Formviews outside grids and nestedviews, I use this code:
(which works fine btw :-)
But inside the nestedview, it seems like I'm not able to address the correct formview - no matter what I try, I always ends up with no file found in the fileupload and null-values in the DB.
NB. The values from Label3 and RadTextBox1 are stored just fine in the DB.
Any helps would be appriciated :-)
Regards
/Berit
My structure looks like this:
<telerik:RadGrid ID="RadGrid1" runat="server"> <MasterTableView> <NestedViewTemplate> <asp:Panel ID="Panel1" runat="server"> <telerik:RadTabStrip ID="RadTabStrip1" runat="server"> <Tabs> <telerik:RadTab runat="server" Text="RadTab1" PageViewID="RadPageView1"></telerik:RadTab> <telerik:RadTab runat="server" Text="RadTab2" PageViewID="RadPageView2"></telerik:RadTab> </Tabs> </telerik:RadTabStrip> <telerik:RadMultiPage ID="RadMultiPage1" runat="server"> <telerik:RadPageView ID="RadPageView1" runat="server"> </telerik:RadPageView> <telerik:RadPageView ID="RadPageView2" runat="server"> <asp:Label ID="Label13" runat="server" Text='<%# Eval("LokationID") %>' Visible="false" /> <asp:FormView ID="FormView1" runat="server" DataSourceID="sdsFile" DataKeyNames="FileID" DefaultMode="Insert" oniteminserting="FormView1_ItemInserting"> <InsertItemTemplate> <table> <tr> <td> <asp:Label ID="Label1" runat="server"> File: (max 1,5GB) </asp:Label> </td> <td> <asp:FileUpload ID="FileUpload1" runat="server" Enabled='<%# Bind("FileDocument") %>' /> </td> </tr> <tr> <td> <asp:Label ID="Label2" runat="server"> Remarks: </asp:Label> </td> <td> <telerik:RadTextBox ID="RadTextBox1" runat="server" Text='<%# Bind("FileRemarks") %>' TextMode="MultiLine"> </telerik:RadTextBox> </td> </tr> <tr> <td colspan="2"> <asp:ImageButton ID="ibtnInsert" runat="server" CommandName="Insert" /> <asp:ImageButton ID="ibtnAbort" runat="server" onclick="ibtnAbort_Click" /> </td> </tr> </table> </InsertItemTemplate> </asp:FormView> <asp:SqlDataSource ID="sdsFile" runat="server" ConnectionString="<%$ ConnectionStrings:AppendoConnStr03 %>" SelectCommand="SELECT FileID, LokationID, FileDocument, FileName, FileExtension, FileMIMEType, FileRemarks FROM Files" InsertCommand="INSERT INTO Files(LokationID, FileDocument, FileName, FileExtension, FileMIMEType, FileRemarks) VALUES (@LokationID, @FileDocument, @FileName, @FileExtension, @FileMIMEType, @FileRemarks)">
<InsertParameters> <asp:ControlParameter ControlID="Label13" PropertyName="Text" Type="Int32" Name="LokationID" /> <asp:Parameter Name="FileDocument" /> <asp:Parameter Name="FileName" /> <asp:Parameter Name="FileExtension" /> <asp:Parameter Name="FileMIMEType" /> <asp:Parameter Name="FileRemarks" /> </InsertParameters> </asp:SqlDataSource> </telerik:RadPageView> </telerik:RadMultiPage> </asp:Panel> </NestedViewTemplate> </MasterTableView> </telerik:RadGrid>When I use FileUploads in Formviews outside grids and nestedviews, I use this code:
(which works fine btw :-)
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e) { FileUpload fileUpload = (FileUpload)FormView1.FindControl("FileUpload1"); if (fileUpload.HasFile) { e.Values["FileName"] = fileUpload.FileName; e.Values["FileExtension"] = Path.GetExtension(fileUpload.PostedFile.FileName).ToLower(); e.Values["FileMIMEType"] = fileUpload.PostedFile.ContentType; e.Values["FileDocument"] = fileUpload.FileBytes; } else { e.Values["FileName"] = null; e.Values["FileExtension"] = null; e.Values["FileMIMEType"] = null; e.Values["FileDocument"] = System.Data.SqlTypes.SqlBinary.Null; } }But inside the nestedview, it seems like I'm not able to address the correct formview - no matter what I try, I always ends up with no file found in the fileupload and null-values in the DB.
NB. The values from Label3 and RadTextBox1 are stored just fine in the DB.
Any helps would be appriciated :-)
Regards
/Berit