I have gridview and
GridViewName.DataSource = table;
table values:
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 get Values:
then, I'm adding new row to table:
DataRow newRow = table.NewRow();
table.Rows.Add(newRow);
and getting values with empty cells (also ID is empty and it's good for me):
then:
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.
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?