Click here to Skip to main content
15,896,379 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have gridview:
C#
GridViewName.DataSource = table;

table values:
C#
string myConnection = ConfigurationManager.ConnectionStrings["vizitka"].ToString();
string Query_sel = MySqlString;
MySqlConnection conDataBase = new MySqlConnection(myConnection);
MySqlCommand cmdDataBase_sel = new MySqlCommand(Query_sel, conDataBase);
  try
  {
     MySqlDataAdapter sda = new MySqlDataAdapter();
     sda.SelectCommand = cmdDataBase_sel;
     DataTable dbdataset = new DataTable();
     sda.Fill(dbdataset);
     BindingSource bSource = new BindingSource();
     bSource.DataSource = dbdataset;
     TableName.DataSource = bSource;
     sda.Update(dbdataset);
   }
     catch (Exception ex)
     {
        MessageBox.Show(ex.Message);
     }

I'm getting Values:
https://i.stack.imgur.com/G561j.jpg[^]

then, I'm adding new row to table:
C#
DataRow newRow = table.NewRow();
table.Rows.Add(newRow);

and getting values with empty cells (also ID is empty and it's good for me):
https://i.stack.imgur.com/quGck.jpg>[^]
then:
C#
GridViewName.DataSource = table;

all is good, but then if I want to delete from table this new created row, I cannot. I'm trying to filter and bind again GridViewName.

What I have tried:

C#
DataView view = new DataView(table);
view.RowFilter = "CONVERT(id, System.String) = null or CONVERT(id, System.String) = ''";
Console.WriteLine(view);

but I'm getting empty table. why?????
Posted
Updated 20-Jan-18 1:18am

1 solution

I found solution:
C#
view.RowFilter = "ID IS NULL";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900