I'm using a gridview that is working off an object data source. The object data source is connected to my class library, which has a function that delivers a data table to the gridview. This is the function:

public DataTable populateGrid(string command)
        {
            DB db = new DB();
            SqlDataAdapter myAdapter = new SqlDataAdapter(command, db.getConn(connString));
            DataTable t = new DataTable();
            myAdapter.Fill(t);
            return t;
        }

The gridview is populated by my data table, but I want to make certain columns of the gridview read-only. How do I do this?

NOTE: I cant add the ReadOnly=true property since the gridview isnt creating any bound fields for some reason.

binding of gridview is done using adapter
is colums are autogenerated / you are using ItemTemplate..

also does you grid involve any edit & delete operations..?

Yes. I created a separate method for them.

is colums are autogenerated / you are using ItemTemplate..

also does you grid involve any edit & delete operations..?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.