TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Daniel Rabinovits
NA
34
7.6k
Initially my ListView shows blank
Apr 10 2019 8:32 PM
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
listView1.Items.Clear();
Approved = false;
string connString = "Data Source=LAPTOP-JTLIEU9Q\\SQLEXPRESS;Initial Catalog=Stores;User ID=sa;Password=Afula1964";
SqlConnection sqlConn = new SqlConnection(connString);
SqlDataAdapter sqlDA = new SqlDataAdapter("spOrderDetails", sqlConn);
sqlDA.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlDA.SelectCommand.Parameters.Add("@OrderID", SqlDbType.VarChar).Value = listBox1.SelectedItem;
DataTable dtSearchResult = new DataTable();
sqlDA.Fill(dtSearchResult);
int fc = dtSearchResult.Columns.Count;
foreach (DataRow row in dtSearchResult.Rows)
{
string[] subitems = new string[fc+1];
object[] o = row.ItemArray;
for (int i = 0; i < fc+1; i++)
{
if (i == 0)
{
subitems[i] = "";
Approved = true;
}
else
{
subitems[i] = o[i-1].ToString();
}
}
if (subitems[4] == "True")
{
subitems[4] = "Yes";
}
else
{
subitems[4] = "No";
}
ListViewItem item = new ListViewItem(subitems);
listView1.Items.Add(item);
}
if (fc > 0)
{
button1.Enabled = true;
}
}
Reply
Answers (
1
)
draw a line in c# application
ListView issue to do with ListView Properties