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

Need help to uplaod XML Files to a SQL database XML type field

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 16 Oct 2015, 07:30 PM

I have simplified it to a ID field and a single XML field for testing. I tried RadUpload and AyncUpload in templates. Have tried gridattachmentcolumn. It will create records, allow me to select the file but it does not upload anything to the XML field/column in the table. So, I have started over and I will place the page here. Currently nothing in code behind.

If you can please help me to do this I would appreciate it. I am novice and taking courses, but already working for a company while attending school.

 

I already know that the SQLDatasource parameter type "Object" is wrong for XML. How to change that SqlDataSource insert and update parameter in code behind? Is that a good strategy? I have tried other types in the SQLDataSource control and have tried to figure out how to make parameters for the SQLDataSource control in code behind but no luck.

Ultimately, I would like to upload the small SVG files to the sql server table and view them within the Radgrid. I seem to have some luck using HTML Object tag in the <ItemTemplate> but cannot test it because I have yet to be able to upload one of the SVG files to the table.

I also had luck setting it up to upload images and view them in a different page. Just cannot figure out how to do this with svg files. 

 

Please help. Since I am learning, a very thorough explanation and example would be appreciated. I have had no luck searching the examples, documentation etc... available here and on searching Google. I have tried a lot of stuff and now pulling my hair out!

 

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="testing.aspx.cs" Inherits="testing" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">     <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" GroupPanelPosition="Top" DataSourceID="SqlDataSource1">         <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1">             <Columns>                 <telerik:GridTemplateColumn DataField="SVGFile" HeaderText="SVGFile" SortExpression="SVGFile" UniqueName="SVGFile" FilterControlAltText="Filter SVGFile column">                     <EditItemTemplate>                         <asp:TextBox runat="server" ID="SVGFileTextBox" Text='<%# Bind("SVGFile") %>'></asp:TextBox>                     </EditItemTemplate>                     <ItemTemplate>                         <asp:Label runat="server" ID="SVGFileLabel" Text='<%# Eval("SVGFile") %>'></asp:Label>                     </ItemTemplate>                 </telerik:GridTemplateColumn
                <telerik:GridBoundColumn DataField="ID" ReadOnly="True" HeaderText="ID" SortExpression="ID" UniqueName="ID" DataType="System.Int32" FilterControlAltText="Filter ID column"></telerik:GridBoundColumn>             </Columns>         </MasterTableView>     </telerik:RadGrid>     <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:IGWiringConnectionString %>' DeleteCommand="DELETE FROM [TestSVG] WHERE [ID] = @ID" InsertCommand="INSERT INTO [TestSVG] ([SVGFile]) VALUES (@SVGFile)" SelectCommand="SELECT [SVGFile], [ID] FROM [TestSVG]" UpdateCommand="UPDATE [TestSVG] SET [SVGFile] = @SVGFile WHERE [ID] = @ID">         <DeleteParameters>             <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>         </DeleteParameters>         <InsertParameters>             <asp:Parameter Name="SVGFile" Type="Object"></asp:Parameter>         </InsertParameters>         <UpdateParameters>             <asp:Parameter Name="SVGFile" Type="Object"></asp:Parameter>             <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>         </UpdateParameters>     </asp:SqlDataSource></asp:Content><asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"></asp:Content>

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 21 Oct 2015, 11:04 AM
Hello Jerry,

In order to implement the behavior you should consider using GridBinaryImageColumn. Check out the following article that describes the column in more details.


Moreover, you can see the behavior in action in the following online example.



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Jerry
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or