Please See the Attachment.
Dear all members,
I want to Bind DatagridView from database just like my Attachment designed
in Windows Application. C#.
How???? (not manual).
Please Help.
i am using that code.
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;
}
}