How to retrive values into DataGridView From a XMLFile using c#.net2.0
-
HI, all i need help reg. datagridview of C# Windows Application. please guide me(if possible with a sample), how to get values from an xml in to Datagridview of C#.net2.0WINDOWS APp thnx in advance,
prashanth, s/w Engineer, Syfnosys.
I am not sure But try creating one dataset and using datasets ReadXML method read the XML file you want. Set datasource as this dataset
Cheers Navaneeth!! www.w3hearts.com
-
HI, all i need help reg. datagridview of C# Windows Application. please guide me(if possible with a sample), how to get values from an xml in to Datagridview of C#.net2.0WINDOWS APp thnx in advance,
prashanth, s/w Engineer, Syfnosys.
Use this Sample............. I have used DataCaching also in it.......... private void Page_Load(object sender, System.EventArgs e) { if(Cache["1"]==null) { FileStream fs = new FileStream(Server.MapPath("simple.xml"),FileMode.Open,FileAccess.Read); CacheDependency cd=new CacheDependency(Server.MapPath("simple.xml")); DataSet ds=new DataSet(); ds.ReadXml(fs); DataView xmldata =new DataView(ds.Tables[0]); Cache["1"]=xmldata; Cache.Insert("1",xmldata,cd); } DataGrid1.DataSource=Cache["1"]; DataGrid1.DataBind(); // Put user code to initialize the page here } With Best Regards, Yogesh
-
HI, all i need help reg. datagridview of C# Windows Application. please guide me(if possible with a sample), how to get values from an xml in to Datagridview of C#.net2.0WINDOWS APp thnx in advance,
prashanth, s/w Engineer, Syfnosys.
You may want to try this: private void cmdGetTrades_Click(object sender, EventArgs e) { dsXML.Clear(); // should already be defined else define it here // allowing user to select file else you can directly hard // code the file name openFileDialog1.Filter = "XML Files|*.xml"; openFileDialog1.Title = "Select SWAPs trades' XML file"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { dsXML.ReadXml(openFileDialog1.FileName); grdTrades.AutoGenerateColumns = true; grdTrades.DataSource = dsXML; grdTrades.DataMember = "trade"; grdTrades.Sort(grdTrades.Columns["TradeID"], ListSortDirection.Ascending); } } I am using this so it certainly works! Hope that helps you. crzYank
-
You may want to try this: private void cmdGetTrades_Click(object sender, EventArgs e) { dsXML.Clear(); // should already be defined else define it here // allowing user to select file else you can directly hard // code the file name openFileDialog1.Filter = "XML Files|*.xml"; openFileDialog1.Title = "Select SWAPs trades' XML file"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { dsXML.ReadXml(openFileDialog1.FileName); grdTrades.AutoGenerateColumns = true; grdTrades.DataSource = dsXML; grdTrades.DataMember = "trade"; grdTrades.Sort(grdTrades.Columns["TradeID"], ListSortDirection.Ascending); } } I am using this so it certainly works! Hope that helps you. crzYank