DataGrid and parsing?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
6 views
There is a code parsing links in the grid and delete the row from the grid(from the base and can't do). But here's the problem, when you press the parsing drops out the window(which I have done(Message) request removal line, and wherein the parsing is not happening. Tell me how can I fix it?

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
/*---Delete rows---*/

if (e.RowIndex != -1)
{
DialogResult result = MessageBox.Show("are you SURE You want to remove the row from the table?",
"Caution. Deleting a row from table", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
switch (result)
{
case DialogResult.Yes:
{
SqlConnection connection = new SqlConnection("server=ROOT-PC\\\\SQLEXPRESS; database=edik; uid=sa; pwd=123321");
connection.Open();
SqlCommand cmdDel = new SqlCommand("DELETE FROM edik_1 WHERE FeedID = @FeedID", connection);
SqlParameter param = new SqlParameter();
param.DbType = DbType.Int32;
param.ParameterName = "@FeedID";
// MessageBox.Show(dataGridView1.CurrentRow.Cells[0].Value.ToString());

//0 is the first cell in the current row of the grid

param.Value = dataGridView1.CurrentRow.Cells[0].Value;
cmdDel.Parameters.Add(param);
byte count = 0;

try
{
count = (byte)cmdDel.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
if ((connection != null))
{
connection.Close();
}
}

if (count > 0)
{
dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
}

if (e.ColumnIndex == 3) dataGridView1.Rows.RemoveAt(e.RowIndex);
else if (e.ColumnIndex == 0)
{
/*---Parsing---*/
XmlTextReader reader = new XmlTextReader((sender as DataGridView)[e.ColumnIndex, e.RowIndex].Value.ToString());
while (reader.Read())
{
switch (reader.Name)
{
case "title":
listBox1.Items.Add(reader.ReadString());
break;
case "link":
listBox1.Items.Add(reader.ReadString());
break;
case "pubDate":
listBox1.Items.Add(reader.ReadString());
listBox1.Items.Add("\");
break;
}
}

}
break;
}

case DialogResult.No:
{
return;
}
}

}
}



Should be like this:

70d404101ff7.jpg

Previously worked, to add some features(which are also needed).


And now, here it is:

3fad6ff55edd.jpg
by | 6 views

1 Answer

0 like 0 dislike
So you have the same first if'Ohm is checking that the row index is not -1 and immediately asks the question about removing. You have another wrap check if (e.ColumnIndex == 3), which goes further in the program text.
by

Related questions

0 like 0 dislike
5 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
asked Mar 28, 2019 by nnmnews
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
27,394 users