We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How do I prevent the datagrid from displaying its append row

I tried doing this in VB but it won't work! dataGrid1.DataSource = dataSet.Tables["customers"].DefaultView; // do not allow an appendrow... ((DataView)dataGrid1.DataSource).AllowNew = false; MY CODE: datagrid1.datasource = dataset.tables ("customer").defaultview CType(datagrid1.datasource, dataview).allowNew = false I cannot change the type of the datasource to a dataview..that's the error!!

2 Replies

CB Clay Burch Syncfusion Team June 1, 2002 08:07 AM UTC

Check your code because I think this should work OK. In the C# code, it was "customers" and in the VB code, it was "customer". Did you mean to have it like this? This code worked for me using the orders table from the northwind database. Dim conStr As String conStr = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:orthwind.mdb" Dim sqlStr As String sqlStr = "SELECT * FROM Employees" ' Create connection object Dim conn As OleDbConnection conn = New OleDbConnection(conStr) ' Create data adapter object Dim da As OleDbDataAdapter da = New OleDbDataAdapter(sqlStr, conn) ' Create a dataset object and fill with data using data adapters Fill method Dim ds As DataSet ds = New DataSet() da.Fill(ds, "Employees") dataGrid1.DataSource = ds.Tables("Employees").DefaultView dim dv as DataView = dataGrid1.DataSource CType(dataGrid1.DataSource, DataView).AllowNew = False


JO jolly June 1, 2002 08:34 AM UTC

Thanks yet again! I'll try that. You have added a dim dv as DataView = dataGrid1.DataSource which i did not do. thanks!! :) > Check your code because I think this should work OK. In the C# code, it was "customers" and in the VB code, it was "customer". Did you mean to have it like this? > > This code worked for me using the orders table from the northwind database. > > > Dim conStr As String > conStr = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:orthwind.mdb" > Dim sqlStr As String > sqlStr = "SELECT * FROM Employees" > ' Create connection object > Dim conn As OleDbConnection > conn = New OleDbConnection(conStr) > ' Create data adapter object > Dim da As OleDbDataAdapter > da = New OleDbDataAdapter(sqlStr, conn) > ' Create a dataset object and fill with data using data adapters Fill method > Dim ds As DataSet > ds = New DataSet() > da.Fill(ds, "Employees") > dataGrid1.DataSource = ds.Tables("Employees").DefaultView > dim dv as DataView = dataGrid1.DataSource > CType(dataGrid1.DataSource, DataView).AllowNew = False >

Loader.
Live Chat Icon For mobile
Up arrow icon