0

Hello Everyone,

Im trying to read an item from combobox. but somehow i getting "system.Data.DataRowView" this only. here is my code

            DataSet ds = new DataSet();
            ds.ReadXml(AppDomain.CurrentDomain.BaseDirectory+ "\\MYFiles\\Books.xml");

            CmbXmlbooks.DisplayMember = "BName";
            CmbXmlbooks.ValueMember = "Isbn";
             CmbXmlbooks.DataSource = ds.Tables[0];

             //Im reading the data from a xml file

private void CmbXmlbooks_SelectedIndexChanged(object sender, EventArgs e)
    {
        LstXmlBooks.Items.Add(CmbXmlbooks.SelectedItem.ToString());
    }

can anyone help to fix this problem

2
Contributors
1
Reply
24
Views
2 Weeks
Discussion Span
Last Post by Titti
1

It should work like this:
you nead to change "NameOfCollum" with your collumn name, or you can use index of collumn..

private void CmbXmlbooks_SelectedIndexChanged(object sender, EventArgs e)
{
    DataRowView d = (DataRowView)CmbXmlbooks.SelectedItem;
    LstXmlBooks.Items.Add(d["NameOfCollum"].ToString());
}

for basic programming commands you can make a look to: http://ctp.mkprog.com/en/

Votes + Comments
Good site tip
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.