Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I created a table in db like this

SQL
CREATE TABLE [dbo].[XmlEmpTable](
 [ID] [int] IDENTITY(1,1) NOT NULL,
 [LoginId] [int] NULL,
 [FormName] [nvarchar](255) NULL,
 [XMLFile] [xml] NULL
 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


I have 3 textboxes and 1 radio button in my aspx page.
I want to insert 3 Textbox values into XMLFile column in xml format.
How can i achieve that?

Anybody please help.

Thanks in advance
Posted
Updated 22-Nov-15 18:16pm
v2
Comments
ArunRajendra 23-Nov-15 0:25am    
What have you tried till now?

1 solution

You can do it in your C# code like-
C#
XElement xml = new XElement("Emp");
            xml.Add(
                new XElement("Field", 
                    new XAttribute("Name", "Field1"), 
                    textbox1.Text),
                 new XAttribute("Name", "Field2"), 
                    textbox2.Text),
                 new XAttribute("Name", "Field3"), 
                    textbox3.Text),
            );

Now pass the value of "xml" for the [XMLFile] field.

Hope, it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900