TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nirmal Roy
NA
365
29.3k
Bind DatagridView from database?
Aug 23 2016 12:54 AM
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;
}
}
Attachment:
datatgrid.rar
Reply
Answers (
9
)
deleting selected button that are in gray color
MVC ActionResult