views:

14

answers:

0

Hello, I am trying to bind a dataset to Listview. I get error at the below line of code :

ListViewItem lvi = new ListViewItem(drow["Roster"].ToString());

the error message is "the overloaded method.... has invalid arguments".

Pasted below is the code.

private void LoadList()
{
    // Get the table from the data set
    DataTable dtable = EmployeDataSet.Tables["Roster"];

    // Clear the ListView control
    ListView1.Items.Clear();

    // Display items in the ListView control
    for (int i = 0; i < dtable.Rows.Count; i++)
    {
        DataRow drow = dtable.Rows[i];

        //// Only row that have not been deleted
       if (drow.RowState != DataRowState.Deleted)
         {
           // Define the list items
            ListViewItem lvi = new ListViewItem(drow["Roster"].ToString());
            lvi.SubItems.Add(drow["title_id"].ToString());
            lvi.SubItems.Add(drow["price"].ToString());
            lvi.SubItems.Add(drow["pubdate"].ToString());

         // Add the list items to the ListView
             listView1.Items.Add(lvi);
        }

Thanks in advance
Madhu