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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I prevent the datagrid from displaying its append row

Thread ID:

Created:

Updated:

Platform:

Replies:

310 Jun 1,2002 06:11 AM UTC Jun 1,2002 08:34 AM UTC Windows Forms 2
loading
Tags: FAQ
jolly
Asked On June 1, 2002 06:11 AM UTC

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!!

Clay Burch [Syncfusion]
Replied On 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:\northwind.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

jolly
Replied On 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:\northwind.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 >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;