k_manimuthu 43 Junior Poster in Training

I derived Datatable in one class(DataTableEx), then i created one property(TotalRecordCount), then i assigned 5000 to that new property(TotalRecordCount), then i convert this datatable into xml, so it's created.Now i try to convert xml to Datatable, i am not able to get 5000 value to TotalRecordCount Property. so how i can get that values

Steps to Execute this application
--------------------------------
Step 1: Comment Following Line
dataTable.ReadXml(@"c:\test.xml");

Step 2: Execute the applicaiton.
Now following xml file(test.xml) will be created.

Step 3: Commont following Lines

dataTable.TotalRecordCount = 5000;
dataTable.WriteXml(@"c:\test.xml", System.Data.XmlWriteMode.WriteSchema);

Step 4: UnComment Following Line
dataTable.ReadXml(@"c:\test.xml");

Step 5: Now the xml file will be convert as a Datatable, but now TotalRecordCount is 0 instead of 5000. To achieve this i overwrite follwoing method "public new void ReadXml(string fileName)" in DatatableEx.xaml.cs.

now i am struggling to fetch "TotalRecordCount" property from xml file, how i can achieve it?
please help me, it's very urgent.

namespace DataTableExApp
{
             public class DataTableEx : DataTable
    {

        public DataTableEx()
            : base()
        {
        }

        public DataTableEx(string tableName)
            : base(tableName)
        {
        }

        public DataTableEx(string tableName, string tableNamespace)
            : base(tableName, tableNamespace)
        {
        }

        public DataTableEx(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        [XmlElement(ElementName = "TotalRecordCount", DataType = "Int")]
        public int TotalRecordCount
        {
            get;
            set;
        }
        
        

        public new void ReadXml(string fileName)
        {
            base.ReadXml(fileName);
//            XmlDocument document = new XmlDocument();
  //          document.Load(fileName);                    

        }
    }
}

namespace DataTableExApp
{
    class Program
    {
        static void Main(string[] args)
        {

            DataTableEx dataTable = new DataTableEx("Test");
            dataTable.TotalRecordCount = 5000;


            dataTable.WriteXml(@"c:\test.xml", System.Data.XmlWriteMode.WriteSchema);

            dataTable.ReadXml(@"c:\test.xml");            

        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.