简体   繁体   中英

Add data manually to gridcontrol devexpress C#

I got into trouble with adding data to devexpress grid programmably. I parse data from the site with HTML Agility Pack and want to add parsed data to grid. I create 13 columns in gridcontrol with wizard.

    private void buttonGetData_Click(object sender, EventArgs e)
    {
        string url = @"____";
        HtmlWeb web = new HtmlWeb();
        HtmlDocument document = web.Load(url);
        var node = document.DocumentNode.SelectNodes("//tr[not(@class)]/td[@style='width:1%;' or @class='coef' or (@class='left' and .//a)]");

        /*foreach (var innerText in node.Select(row => row.InnerText))
        {
            gridView1.AddNewRow();
            gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["colunmDate"] , innerText);
            gridView1.UpdateCurrentRow();
        }*/
    }

I get about 2000 elements into node. In this code i get InnerText from Node. Commented code doesn't work (and it's just for test). Please, help me with adding data to DevExpress Grid. Thanks!

Assuming that document variable is well formed Xml you can load this into DataSet instance as

XmlTextReader MyReader = new XmlTextReader(new StringReader(Buffer));
MyDataSet.ReadXml(MyReader, XmlReadMode.Auto);

Then you may attach appropriate table as GridView1.DataSource directly or transform it before attaching.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM