How to bind selected columns to datagridview at runtime.
I have written select * from tableName. And result i have stored in DataTable dt. Now i want only selected columns to be displayed in datagridview at runtime. I dont want to bound gridview at designtime.

Recommended Answers

All 4 Replies

Actuly i can write only required column name but my query is parameterized and cloumn which i am using for parameter that i dont wont to display

And other columns i am binding with other labels so thats why i have to do * option.

Thanks hericles its working.
All i have done is instead of writing DataGridViewTextBoxColumn i have written DataGridViewColumn. And DataGridViewColumn's obj.CellTemplate = new DataGridViewTextBoxCell(); because DataGridViewTextBoxColumn do not have DataPropertyName property.
Thank you your link was helpfull

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.