ListView listView1 = new ListView();
DataTable dataTable = new DataTable();
MoneyReceiptGateway moneyReceiptGateway = new MoneyReceiptGateway();
dataTable = moneyReceiptGateway.SelectDataForListView(narrationTextBox.Text);
string[] str = new string[dataTable.Columns.Count];
foreach (DataRow rr in dataTable.Rows)
{
for (int coll = 0; coll <= dataTable.Columns.Count; coll++)
{
str[coll] = rr[coll].ToString();
}
ListViewDataItem li;
li = new ListViewDataItem(str);
listView1.Items.Add(li);
}
public DataTable SelectDataForListView(string txtSubHead)
{
int length = txtSubHead.Length;
string aa = txtSubHead.Substring(0, length);
connection = ConfigurationManager.AppSettings["ConnectionString"];
sqlConnectionObj = new SqlConnection(this.connection);
string insertQuery = @"select S.SubName,M.MainName, A.ClassName from AcClass as A, MainClass as M, SubClass as S WHERE (S.AcCode=A.AcCode) and (S.AcCode=M.AcCode)
and (S.MainCode=M.MainCode) and (substring(S.subname,1,'" + length + "')='" + txtSubHead + "') or (substring(M.MainName,1,'" + length + "')='" + txtSubHead + "' ) ORDER BY S.SubName";
sqlConnectionObj.Open();
adapter = new SqlDataAdapter(insertQuery, sqlConnectionObj);
dataTable=new DataTable();
adapter.Fill(dataTable);
return dataTable;
}
error message is:Error 3 The best overloaded method match for 'System.Windows.Forms.ListView.ListViewItemCollection.Add(string)' has some invalid argument