how to read from a dataset datatable and add 3rd  row into listbox

Posted on 2007-08-07
Last Modified: 2013-12-17
i got 2 datasets i wan to read data from the 2 nd table of datset and diplay the 3 rd colum values into the list box  when i press insert button can any one help me
and also remove button
when i click a particular one and prese remove that should be removed and when i select all all should be reoved can any help me with this please
Question by:kranthi4uonly
    LVL 8

    Expert Comment

    DataSet ds1 = new DataSet();
            DataSet ds2 = new DataSet();
            ListBox lst = new ListBox();
            foreach(DataRow row in ds1.Tables[1].Rows)
    LVL 5

    Expert Comment

    To remove a selected row
    DataRow selectedRow = dataTable.Rows[listBox1.SelectedIndex];

    LVL 2

    Accepted Solution

    To Load Table Values from Dataset use following code
    (It is just an Example Code, Modify it as per your requirement)

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

        // Clear the ListView control

        // 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["title"].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

    Now, to remove Row From DataTable:

    You will get the Index of the row from Listview which you want to delete . You can use this Index to delete actual row from DataTable. The code is as follows


    Wish you best luck
    (NOTE: Never use numerical values in your code, always use names or define constant values)


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now