Hi
How can I check whether a listview has text in a particular row?Is there a method like
if(istviewname.Items[row no].Text ==" ")
{code}
else if(istviewname.Items[row no].Text !=" ")
{ code}
Can anyone help me?
Thanx

Hello Lakshith you are most welcome on DANIWEB!
Of course there is a method! You've just wrtten it.
Two remarks:
***> " " is text, it is a string containing one char: the space. Use "" or string.Empty here.
***> because you test for two opposite things you don't have to test them both. If one is true then the other is false.
Use this:

if(istviewname.Items[row no].Text == String.Empty)
{code}
else 
{ code}

Hi Thanx 4 da help dannbe.But it ddnt wrk.When i entered only 2 rows the 3rd row gave an exception.Cn u gv me anothr tip?

well there are 15 columns in Access database like Amount1,Invoice no 1,Description1,Amount2,nvoice no 2,Description2...upto Amount5,Invoice no 5,Description5 .The maximum no fo rows i wnt 2 enter is therefore 5 and the minimum is 1.Error ocuurs when i want 2 enter rows in between 1 and 5 i.e when i enter only 2 rows or 3 or 4 or 5

Try to write decent English this becomes important in cases like this, where you are discussing row 2 to 5. (or should I say: row 2 2 5?)
In answering my question you mention something about columns, so I just pose my question again: How many rows are there in your listview?

Sorry I overlooked the word Access db. I think in that case you are better of with a DataGridView instead of a ListView

There are 5 rows.But in my application I dont insert data into all 5 rows eveytime.So the Exception comes when I dont insert data into all 5 rows.

I presume that your program uses DataTable. Here is sample,

DataTable dt = new DataTable();
            dt.Columns.Add("No",typeof(long));
            dt.Columns.Add("Name");
            dt.Rows.Add(1, "A");
            dt.Rows.Add(2, "B");

            listView1.View = View.Details;
            int i;
            // Header
            for (i = 0; i < dt.Columns.Count; i++)
                listView1.Columns.Add(dt.Columns[i].ColumnName);

            // Rows
            for (i = 0; i < dt.Rows.Count; i++)
            {
                string[] ar = new string[dt.Columns.Count];
                for (int j = 0; j < dt.Columns.Count; j++)
                    ar[j] = dt.Rows[i][j].ToString();

                ListViewItem item = new ListViewItem(ar);
                listView1.Items.Add(item);
            }
This article has been dead for over six months. Start a new discussion instead.