Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. building an XML page

building an XML page

Scheduled Pinned Locked Moved XML / XSL
helpcsharptutorialannouncementxml
10 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Farraj
    wrote on last edited by
    #1

    Hello Coders, Im facing a problem building a C#.net code that will build me the following XML page:

    <?xml version="1.0"?>
    <chores>
    <day title="some title">
    <job a=".." b="text.." c="..text.." d="d..."/>
    <job a=".." b="text.." c="..text.." d="d..."/>
    <job a=".." b="text.." c="..text.." d="d..."/>
    </day>

    //updating a new DAY tag

    <day title="some title">
    <job a=".." b="text.." c="..text.." d="d..."/>
    <job a=".." b="text.." c="..text.." d="d..."/>
    <job a=".." b="text.." c="..text.." d="d..."/>
    </day>
    //and again.. etc..

    <day title="some title">
    <job a=".." b="text.." c="..text.." d="d..."/>
    <job a=".." b="text.." c="..text.." d="d..."/>
    <job a=".." b="text.." c="..text.." d="d..."/>
    </day>

    </chores>

    I've tried hundreds of codes, nothing worked the way i need it. i will appreciate any help PLEASE. What im trying to do is the following: I have a page that has 4 textboxes, each one is supposed to save some value .. lets say a,b,c,d.. Another textbox is for the day attribute which is TITLE according to my example I need to add whenever i need a DAY. with it's attribute. and "jobs" like that example. whenever i need to make a new "DAY" i need it do be after the last one. i mean i need it to update the new <DAY> after the last one's and all of that i need it to come before the each time i update the xml file</chores> Please i'd really appreciate any help with this. im new to XML and im trying to make an XML management page for some project.If what i've said wasnt clear im ready to explain again. Please tell me what to do and how to do it, or if you have any samples for handling such an issue it will be great too

    E F 2 Replies Last reply
    0
    • F Farraj

      Hello Coders, Im facing a problem building a C#.net code that will build me the following XML page:

      <?xml version="1.0"?>
      <chores>
      <day title="some title">
      <job a=".." b="text.." c="..text.." d="d..."/>
      <job a=".." b="text.." c="..text.." d="d..."/>
      <job a=".." b="text.." c="..text.." d="d..."/>
      </day>

      //updating a new DAY tag

      <day title="some title">
      <job a=".." b="text.." c="..text.." d="d..."/>
      <job a=".." b="text.." c="..text.." d="d..."/>
      <job a=".." b="text.." c="..text.." d="d..."/>
      </day>
      //and again.. etc..

      <day title="some title">
      <job a=".." b="text.." c="..text.." d="d..."/>
      <job a=".." b="text.." c="..text.." d="d..."/>
      <job a=".." b="text.." c="..text.." d="d..."/>
      </day>

      </chores>

      I've tried hundreds of codes, nothing worked the way i need it. i will appreciate any help PLEASE. What im trying to do is the following: I have a page that has 4 textboxes, each one is supposed to save some value .. lets say a,b,c,d.. Another textbox is for the day attribute which is TITLE according to my example I need to add whenever i need a DAY. with it's attribute. and "jobs" like that example. whenever i need to make a new "DAY" i need it do be after the last one. i mean i need it to update the new <DAY> after the last one's and all of that i need it to come before the each time i update the xml file</chores> Please i'd really appreciate any help with this. im new to XML and im trying to make an XML management page for some project.If what i've said wasnt clear im ready to explain again. Please tell me what to do and how to do it, or if you have any samples for handling such an issue it will be great too

      E Offline
      E Offline
      Estys
      wrote on last edited by
      #2

      Can you show us a little of what you tried? What you are trying to do is maintaining a kind of database. On the assumption that you really want it as xml-file : option 1 : Read your file as XmlDocument and add nodes as you add entries. option 2 : Create a dedicated class model with serializing/deserializing. Both methods have as disadvantage that everything get loaded in memory. To prevent that you might have to split your model in multiple files. Google for XmlDocument and/or XSD utility. If you need further clarification, just ask.

      F 1 Reply Last reply
      0
      • E Estys

        Can you show us a little of what you tried? What you are trying to do is maintaining a kind of database. On the assumption that you really want it as xml-file : option 1 : Read your file as XmlDocument and add nodes as you add entries. option 2 : Create a dedicated class model with serializing/deserializing. Both methods have as disadvantage that everything get loaded in memory. To prevent that you might have to split your model in multiple files. Google for XmlDocument and/or XSD utility. If you need further clarification, just ask.

        F Offline
        F Offline
        Farraj
        wrote on last edited by
        #3

        i've tried this code for example

        XmlDocument XDoc = new XmlDocument();
        XmlElement Xchores = XDoc.CreateElement("day");
        XmlElement XElemRoot = XDoc.CreateElement("chores");
        XElemRoot.AppendChild(Xchores);
        Xchores.SetAttribute("label", "" + this.txtBoxCat.Text + "");
        // Create root node.
        //Add the node to the document.
        XDoc.AppendChild(XElemRoot);
        XmlElement Xjob = XDoc.CreateElement("job");
        while (this.Label5.Text == "1")
        {
        Xjob.SetAttribute("a", "" + this.txtBoxAbout.Text + "");
        Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
        Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
        Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "");
        Xchores.AppendChild(Xjob);
        XDoc.Save("chores2.xml");
        }

        and ive tried it by making a dataset of the elements

        DataSet ds = new DataSet();
            ds.ReadXml("chores2.xml");        DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("a"));
            dt.Columns.Add(new DataColumn("b"));
            dt.Columns.Add(new DataColumn("c"));
            dt.Columns.Add(new DataColumn("d"));
            DataRow dr = dt.NewRow();
            dr\[0\] = ""+this.txtBoxSize.Text+"";
            dr\[1\] = "" + this.txtBoxAbout.Text + "";
            dr\[2\] = "" + this.txtBoxAmount.Text + "";
            dr\[3\] = "" + this.txtBoxSize.Text + "";
            dt.Rows.Add(dr);
            ds.Tables.Add(dt);
            ds.Relations.Add(new
        

        DataRelation("myrel", ds.Tables[1].Columns[0], ds.Tables[0].Columns[0]));
        ds.Relations[0].Nested = true;
        ds.WriteXml("chores2.xml");

        and i've tried it by getting the values from an access database and save them as an XML file also that didnt help approaching my goal

        OleDbConnection con = new OleDbConnection();
        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
        OleDbDataAdapter da = new OleDbDataAdapter("Select * from job1", con);
        DataSet ds = new DataSet("chores");
        DataTable xjob = new DataTable();
        xjob = xjob.Tables["job"];
        da.Fill(ds, "day");
        ds.WriteXml("chores2.xml");
        */
        string jobName = this.TextBox2.Text;
        OleDbConnection con = new OleDbConnection();
        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
        OleDbDataAdapter da = new OleDbDataAdapter("Select * from "+jobName+"",

        E 1 Reply Last reply
        0
        • F Farraj

          i've tried this code for example

          XmlDocument XDoc = new XmlDocument();
          XmlElement Xchores = XDoc.CreateElement("day");
          XmlElement XElemRoot = XDoc.CreateElement("chores");
          XElemRoot.AppendChild(Xchores);
          Xchores.SetAttribute("label", "" + this.txtBoxCat.Text + "");
          // Create root node.
          //Add the node to the document.
          XDoc.AppendChild(XElemRoot);
          XmlElement Xjob = XDoc.CreateElement("job");
          while (this.Label5.Text == "1")
          {
          Xjob.SetAttribute("a", "" + this.txtBoxAbout.Text + "");
          Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
          Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
          Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "");
          Xchores.AppendChild(Xjob);
          XDoc.Save("chores2.xml");
          }

          and ive tried it by making a dataset of the elements

          DataSet ds = new DataSet();
              ds.ReadXml("chores2.xml");        DataTable dt = new DataTable();
              dt.Columns.Add(new DataColumn("a"));
              dt.Columns.Add(new DataColumn("b"));
              dt.Columns.Add(new DataColumn("c"));
              dt.Columns.Add(new DataColumn("d"));
              DataRow dr = dt.NewRow();
              dr\[0\] = ""+this.txtBoxSize.Text+"";
              dr\[1\] = "" + this.txtBoxAbout.Text + "";
              dr\[2\] = "" + this.txtBoxAmount.Text + "";
              dr\[3\] = "" + this.txtBoxSize.Text + "";
              dt.Rows.Add(dr);
              ds.Tables.Add(dt);
              ds.Relations.Add(new
          

          DataRelation("myrel", ds.Tables[1].Columns[0], ds.Tables[0].Columns[0]));
          ds.Relations[0].Nested = true;
          ds.WriteXml("chores2.xml");

          and i've tried it by getting the values from an access database and save them as an XML file also that didnt help approaching my goal

          OleDbConnection con = new OleDbConnection();
          con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
          OleDbDataAdapter da = new OleDbDataAdapter("Select * from job1", con);
          DataSet ds = new DataSet("chores");
          DataTable xjob = new DataTable();
          xjob = xjob.Tables["job"];
          da.Fill(ds, "day");
          ds.WriteXml("chores2.xml");
          */
          string jobName = this.TextBox2.Text;
          OleDbConnection con = new OleDbConnection();
          con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
          OleDbDataAdapter da = new OleDbDataAdapter("Select * from "+jobName+"",

          E Offline
          E Offline
          Estys
          wrote on last edited by
          #4

          Your approach with XmlDocument in itself works, I tried your code. What you need to to there is first checking if the file exists and if so xDoc.Load();.

                  FileInfo fi1 = new System.IO.FileInfo(@"c:\\temp\\chores2.xml");
          
                  if (!fi1.Exists) 
                  {
                      XDoc.Load(@"c:\\temp\\chores2.xml")
                  }
                  else
                  {
                      XmlElement XElemRoot = XDoc.CreateElement("chores");
                      XDoc.AppendChild(XElemRoot);
                  }
          

          To add a job to a particular day you need to find the node with the right title :

          XDoc.SelectSingleNode("descendant::day[@title='YourTitle']");

          You can now add your jobs to it. About option 2, MS has a utility called XSD. On my PC it's in :

          C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\xsd.exe

          With your xml you can generate an xsd, and with the xsd you can generate a .cs file. It has all the classes and attributes you need. You can and should edit it to suit your needs. The only thing left to do is write a serializer and a deserializer. The code would look something like this (I removed all attributes)

          public partial class chores {

          private choresDay\[\] itemsField;
          
          public choresDay\[\] Items {
              get {
                  return this.itemsField;
              }
              set {
                  this.itemsField = value;
              }
          }
          

          }

          public partial class choresDay {

          private choresDayJob\[\] jobField;
          
          private string titleField;
          
          public choresDayJob\[\] job {
              get {
                  return this.jobField;
              }
              set {
                  this.jobField = value;
              }
          }
          
          public string title {
              get {
                  return this.titleField;
              }
              set {
                  this.titleField = value;
              }
          }
          

          }

          public partial class choresDayJob {

          private string aField;
          
          private string bField;
          
          private string cField;
          
          private string dField;
          
          public string a {
              get {
                  return this.aField;
              }
              set {
                  this.aField = value;
              }
          }
          
          public string b {
              get {
                  return this.bField;
              }
              set {
                  this.bField = value;
              }
          }
          
          public string c {
              get {
                  return this.cField;
              }
              set {
                  this.cField = value;
              }
          }
          
          publ
          
          F 1 Reply Last reply
          0
          • E Estys

            Your approach with XmlDocument in itself works, I tried your code. What you need to to there is first checking if the file exists and if so xDoc.Load();.

                    FileInfo fi1 = new System.IO.FileInfo(@"c:\\temp\\chores2.xml");
            
                    if (!fi1.Exists) 
                    {
                        XDoc.Load(@"c:\\temp\\chores2.xml")
                    }
                    else
                    {
                        XmlElement XElemRoot = XDoc.CreateElement("chores");
                        XDoc.AppendChild(XElemRoot);
                    }
            

            To add a job to a particular day you need to find the node with the right title :

            XDoc.SelectSingleNode("descendant::day[@title='YourTitle']");

            You can now add your jobs to it. About option 2, MS has a utility called XSD. On my PC it's in :

            C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\xsd.exe

            With your xml you can generate an xsd, and with the xsd you can generate a .cs file. It has all the classes and attributes you need. You can and should edit it to suit your needs. The only thing left to do is write a serializer and a deserializer. The code would look something like this (I removed all attributes)

            public partial class chores {

            private choresDay\[\] itemsField;
            
            public choresDay\[\] Items {
                get {
                    return this.itemsField;
                }
                set {
                    this.itemsField = value;
                }
            }
            

            }

            public partial class choresDay {

            private choresDayJob\[\] jobField;
            
            private string titleField;
            
            public choresDayJob\[\] job {
                get {
                    return this.jobField;
                }
                set {
                    this.jobField = value;
                }
            }
            
            public string title {
                get {
                    return this.titleField;
                }
                set {
                    this.titleField = value;
                }
            }
            

            }

            public partial class choresDayJob {

            private string aField;
            
            private string bField;
            
            private string cField;
            
            private string dField;
            
            public string a {
                get {
                    return this.aField;
                }
                set {
                    this.aField = value;
                }
            }
            
            public string b {
                get {
                    return this.bField;
                }
                set {
                    this.bField = value;
                }
            }
            
            public string c {
                get {
                    return this.cField;
                }
                set {
                    this.cField = value;
                }
            }
            
            publ
            
            F Offline
            F Offline
            Farraj
            wrote on last edited by
            #5

            Hi Estys, First of all thank you a lot for your help and time, i really appreciate that. Second, i think im gonna take option #1:) lol. Anyway, this is the code i've made for now, im not sure about it but i'd really appreciate more help.

            protected void Button1_Click(object sender, EventArgs e)
            {
            XmlDocument XDoc = new XmlDocument();
            FileInfo fi1 = new System.IO.FileInfo("chores2.xml");
            if (!fi1.Exists)
            {

                    XDoc.Load("chores2.xml");
                }
            
                else
                {
                    
                   
                    XmlNode root = XDoc.DocumentElement;
                    XDoc.SelectSingleNode("descendant::day\[@title='"+this.dropdwnlst.selectedvalue+"'\]");
            
                    XmlElement Xjob = XDoc.CreateElement("job");
                    Xjob.SetAttribute("a", "" + this.txtBoxProduct.Text + "");
                    Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
                    Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
                    Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "")
                    XDoc.Save("chores2.xml");
                }
            

            }

            this is what im thinking about, i have 4 text boxes for the job attributes. with another DropDownList that through it i can choose what kind of a "DAY" according to the title i want to play with and add "jobs". So, this cute line

            XDoc.SelectSingleNode("descendant::day[@title='"+this.dropdwnlst.selectedvalue+"']");

            is really great, but how i can control my selected node and enter the correct attributes

            Xjob.SetAttribute("a", "" + this.txtBoxProduct.Text + "");
            Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
            Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
            Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "")

            to it? Thanks again for your help.

            E 1 Reply Last reply
            0
            • F Farraj

              Hi Estys, First of all thank you a lot for your help and time, i really appreciate that. Second, i think im gonna take option #1:) lol. Anyway, this is the code i've made for now, im not sure about it but i'd really appreciate more help.

              protected void Button1_Click(object sender, EventArgs e)
              {
              XmlDocument XDoc = new XmlDocument();
              FileInfo fi1 = new System.IO.FileInfo("chores2.xml");
              if (!fi1.Exists)
              {

                      XDoc.Load("chores2.xml");
                  }
              
                  else
                  {
                      
                     
                      XmlNode root = XDoc.DocumentElement;
                      XDoc.SelectSingleNode("descendant::day\[@title='"+this.dropdwnlst.selectedvalue+"'\]");
              
                      XmlElement Xjob = XDoc.CreateElement("job");
                      Xjob.SetAttribute("a", "" + this.txtBoxProduct.Text + "");
                      Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
                      Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
                      Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "")
                      XDoc.Save("chores2.xml");
                  }
              

              }

              this is what im thinking about, i have 4 text boxes for the job attributes. with another DropDownList that through it i can choose what kind of a "DAY" according to the title i want to play with and add "jobs". So, this cute line

              XDoc.SelectSingleNode("descendant::day[@title='"+this.dropdwnlst.selectedvalue+"']");

              is really great, but how i can control my selected node and enter the correct attributes

              Xjob.SetAttribute("a", "" + this.txtBoxProduct.Text + "");
              Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
              Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
              Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "")

              to it? Thanks again for your help.

              E Offline
              E Offline
              Estys
              wrote on last edited by
              #6

              Your form code should look like this :

              public partial class choreForm : Form
              {
                  XmlDocument xDoc = new XmlDocument();
              
                  public choreForm()
                  {
                      InitializeComponent();
                  }
              
                  private void choreForm\_Load(object sender, EventArgs e)
                  {
                      FileInfo fi1 = new FileInfo(GetFileName());
              
                      if (fi1.Exists)
                      {
                          xDoc.Load(GetFileName());
                      }
                      else
                      {
                          xDoc.AppendChild(xDoc.CreateElement("chores"));
                      }
                  }
              
                  private void button1\_Click(object sender, EventArgs e)
                  {
                      **XmlElement xDay = xDoc.SelectSingleNode("descendant::day\[@title='" + this.dropdwnlst.selectedvalue + "'\]") as XmlElement;
              
                      if (xDay == null)
                      {
                          xDay = xDoc.CreateElement("day");
                          xDay.SetAttribute("title", this.dropdwnlst.selectedvalue);
                          xDoc.FirstChild.AppendChild(xDay);
                      }**
              
                      XmlElement xJob = xDoc.CreateElement("job");
                      xJob.SetAttribute("a", this.txtBoxProduct.Text);
                      xJob.SetAttribute("b", this.txtBoxSize.Text);
                      xJob.SetAttribute("c", this.txtBoxPrice.Text);
                      xJob.SetAttribute("d", this.txtBoxAmount.Text);
                      **xDay.AppendChild(xJob);**
              
                  }
              
                  private void choreForm\_FormClosing(object sender, FormClosingEventArgs e)
                  {
                      xDoc.Save(GetFileName());
                  }
              
                  private string GetFileName()
                  {
                      return @"c:\\temp\\chores2.xml";
                  }
              }
              

              gimme 5 if you like this!

              F 1 Reply Last reply
              0
              • E Estys

                Your form code should look like this :

                public partial class choreForm : Form
                {
                    XmlDocument xDoc = new XmlDocument();
                
                    public choreForm()
                    {
                        InitializeComponent();
                    }
                
                    private void choreForm\_Load(object sender, EventArgs e)
                    {
                        FileInfo fi1 = new FileInfo(GetFileName());
                
                        if (fi1.Exists)
                        {
                            xDoc.Load(GetFileName());
                        }
                        else
                        {
                            xDoc.AppendChild(xDoc.CreateElement("chores"));
                        }
                    }
                
                    private void button1\_Click(object sender, EventArgs e)
                    {
                        **XmlElement xDay = xDoc.SelectSingleNode("descendant::day\[@title='" + this.dropdwnlst.selectedvalue + "'\]") as XmlElement;
                
                        if (xDay == null)
                        {
                            xDay = xDoc.CreateElement("day");
                            xDay.SetAttribute("title", this.dropdwnlst.selectedvalue);
                            xDoc.FirstChild.AppendChild(xDay);
                        }**
                
                        XmlElement xJob = xDoc.CreateElement("job");
                        xJob.SetAttribute("a", this.txtBoxProduct.Text);
                        xJob.SetAttribute("b", this.txtBoxSize.Text);
                        xJob.SetAttribute("c", this.txtBoxPrice.Text);
                        xJob.SetAttribute("d", this.txtBoxAmount.Text);
                        **xDay.AppendChild(xJob);**
                
                    }
                
                    private void choreForm\_FormClosing(object sender, FormClosingEventArgs e)
                    {
                        xDoc.Save(GetFileName());
                    }
                
                    private string GetFileName()
                    {
                        return @"c:\\temp\\chores2.xml";
                    }
                }
                

                gimme 5 if you like this!

                F Offline
                F Offline
                Farraj
                wrote on last edited by
                #7

                I LOVE IT!! this code is perfect!!! i've been blessed by a genius coder THANK U ALOT for ur time and help!! PERFECT :))))))))))))))))))))))

                1 Reply Last reply
                0
                • F Farraj

                  Hello Coders, Im facing a problem building a C#.net code that will build me the following XML page:

                  <?xml version="1.0"?>
                  <chores>
                  <day title="some title">
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  </day>

                  //updating a new DAY tag

                  <day title="some title">
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  </day>
                  //and again.. etc..

                  <day title="some title">
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  <job a=".." b="text.." c="..text.." d="d..."/>
                  </day>

                  </chores>

                  I've tried hundreds of codes, nothing worked the way i need it. i will appreciate any help PLEASE. What im trying to do is the following: I have a page that has 4 textboxes, each one is supposed to save some value .. lets say a,b,c,d.. Another textbox is for the day attribute which is TITLE according to my example I need to add whenever i need a DAY. with it's attribute. and "jobs" like that example. whenever i need to make a new "DAY" i need it do be after the last one. i mean i need it to update the new <DAY> after the last one's and all of that i need it to come before the each time i update the xml file</chores> Please i'd really appreciate any help with this. im new to XML and im trying to make an XML management page for some project.If what i've said wasnt clear im ready to explain again. Please tell me what to do and how to do it, or if you have any samples for handling such an issue it will be great too

                  F Offline
                  F Offline
                  Farraj
                  wrote on last edited by
                  #8

                  Hi again :-) thanks for your help with adding the XML data i need to ask you another question i've got my final xml file looking exactly as i need it to be

                  <?xml version="1.0" encoding="utf-8"?>
                  <chores>
                  <day label="111" title="asdasd">
                  <job a="2" b="22" c="22" d="22" />
                  <job a="2" b="22" c="22" d="22" />
                  </day>
                  </chores>

                  im trying to Edit this file in a dataGrid but its not working my aspx page

                  <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="EditTables.aspx.cs" Inherits="EditTables" %>

                  <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
                  <style type="text/css">
                  .style1
                  {
                  width: 100%;
                  }
                  </style>
                  </asp:Content>
                  <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
                  <table class="style1">
                  <tr>
                  <td>
                  <br />
                  <br />
                  Edit your Products tables<br />
                  </td>
                  </tr>
                  <tr>
                  <td>
                   <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True"
                  AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None"
                  oncancelcommand="DataGrid1_CancelCommand"
                  ondeletecommand="DataGrid1_DeleteCommand" oneditcommand="DataGrid1_EditCommand"
                  onpageindexchanged="DataGrid1_PageIndexChanged"
                  onupdatecommand="DataGrid1_UpdateCommand" AutoGenerateColumns="False"
                  Width="890px">
                  <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
                  <Columns>
                  <asp:TemplateColumn HeaderText=" label">
                  <ItemTemplate>
                  <%# DataBinder.Eval(Container.DataItem, "label")%>
                  </ItemTemplate>
                  <EditItemTemplate>
                  <asp:TextBox id="txtBoxTitle"
                  Text='<%# DataBinder.Eval(Container.DataItem, "label") %>'
                  runat="server" Height="21px" Width="80px"/>
                  </EditItemTemplate>
                  </asp:TemplateColumn>

                         <asp:TemplateColumn HeaderText="title">
                          <ItemTemplate&g
                  
                  E 1 Reply Last reply
                  0
                  • F Farraj

                    Hi again :-) thanks for your help with adding the XML data i need to ask you another question i've got my final xml file looking exactly as i need it to be

                    <?xml version="1.0" encoding="utf-8"?>
                    <chores>
                    <day label="111" title="asdasd">
                    <job a="2" b="22" c="22" d="22" />
                    <job a="2" b="22" c="22" d="22" />
                    </day>
                    </chores>

                    im trying to Edit this file in a dataGrid but its not working my aspx page

                    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="EditTables.aspx.cs" Inherits="EditTables" %>

                    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
                    <style type="text/css">
                    .style1
                    {
                    width: 100%;
                    }
                    </style>
                    </asp:Content>
                    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
                    <table class="style1">
                    <tr>
                    <td>
                    <br />
                    <br />
                    Edit your Products tables<br />
                    </td>
                    </tr>
                    <tr>
                    <td>
                     <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True"
                    AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None"
                    oncancelcommand="DataGrid1_CancelCommand"
                    ondeletecommand="DataGrid1_DeleteCommand" oneditcommand="DataGrid1_EditCommand"
                    onpageindexchanged="DataGrid1_PageIndexChanged"
                    onupdatecommand="DataGrid1_UpdateCommand" AutoGenerateColumns="False"
                    Width="890px">
                    <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                    <asp:TemplateColumn HeaderText=" label">
                    <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "label")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                    <asp:TextBox id="txtBoxTitle"
                    Text='<%# DataBinder.Eval(Container.DataItem, "label") %>'
                    runat="server" Height="21px" Width="80px"/>
                    </EditItemTemplate>
                    </asp:TemplateColumn>

                           <asp:TemplateColumn HeaderText="title">
                            <ItemTemplate&g
                    
                    E Offline
                    E Offline
                    Estys
                    wrote on last edited by
                    #9

                    Actually, your DataSet contains two Tables : day and job, I guess that's where the problems start. I'm not very familiar with databinding, I would ask in another forum (as this whole question probably should have been :) ). The problem is not the attributes, the "title" and "label" attributes are acceptable to the binder. Also the other attributes ARE present as columns in table "job". So, post this question in the ASP or Web Development corner of CP. Cheers

                    F 1 Reply Last reply
                    0
                    • E Estys

                      Actually, your DataSet contains two Tables : day and job, I guess that's where the problems start. I'm not very familiar with databinding, I would ask in another forum (as this whole question probably should have been :) ). The problem is not the attributes, the "title" and "label" attributes are acceptable to the binder. Also the other attributes ARE present as columns in table "job". So, post this question in the ASP or Web Development corner of CP. Cheers

                      F Offline
                      F Offline
                      Farraj
                      wrote on last edited by
                      #10

                      Hi i created a dropdownlist that shows all the ((day- label attribute)). by selecting one of those item, it will bind all that selected node's data in a datagrid. In other words, how can i bind the selected node from the dropdownlist to a datagrid that will bind its attributes?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups