private void binddata() { SqlDataAdapter da = new SqlDataAdapter(@"SELECT distinct Sectiontype + ' ' + '['+ Questiontype + ']' + ' ' + 'Attempt Question :-' + ' ' + Attemptquestion + ' ' + 'Total Marks :-' + ' ' + Totalmarks as 'Groupst', Question,Fullmarks FROM dbo.tbl_QuestionConfig where Subject='C++' group by Sectiontype + ' ' + '['+ Questiontype + ']' + ' ' + 'Attempt Question :-' + ' ' + Attemptquestion + ' ' + 'Total Marks :-' + ' ' + Totalmarks ,Question,Fullmarks", con); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); if (dt.Rows.Count > 0) { dataGridView1.DataSource = dt; dataGridView1.AutoGenerateColumns = false; dataGridView1.AllowUserToAddRows = false; dataGridView1.EnableHeadersVisualStyles = false; dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSeaGreen; foreach (DataGridViewRow r in dataGridView1.Rows) { r.DefaultCellStyle.BackColor = Color.LightCyan; } }
dataGridView1.AutoGenerateColumns = false;
dataGridView1.AutoGenerateColumns = true;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)