alternatefaraz
alternatefaraz

Reputation: 374

How to stop grid view from creating more rows

I am creating grid view through data adapter and all columns and rows are created from data base but problem occurs that when rows all rows are created there comes another empty row i want to stop that row to be generated and when i click and some value in that extra row another new row is created i want to stop all extra rows how to do this any help???

this is the grid view code i am using

            conn.ConnectionString = s;
            conn.Open();
            dAdapter = new SqlDataAdapter(query, s);
            dTable = new DataTable();
            DataView myDataView = dTable.DefaultView;
            dAdapter.Fill(dTable);
            BindingSource bndSource = new BindingSource();
            bndSource.DataSource = dTable;
            dataGrid.DataSource = bndSource;
            dataGrid.Columns["StudentId"].ReadOnly = true;
            dataGrid.Columns["StudentName"].ReadOnly = true;
            conn.Close();

Upvotes: 0

Views: 247

Answers (1)

pete
pete

Reputation: 25091

Try setting AllowUserToAddRows to false.

Upvotes: 1

Related Questions