Link to home
Start Free TrialLog in
Avatar of kinton
kinton

asked on

C#.Net Data Grid View

Hi,

I have a data grid view on my c#.net form.

I want to populate the data grid view from a dataset that I have been passed, however I can't bind directly to the dataset as I want columns 1 and 2 from the dataset in column one of the data grid view, I also want to make certain rows bold based on certain conditions.

I assume the easiest way to do this it to loop round my dataset and add each row one at a time.

the code below is on the in my for loop.  However, when I run it only the last row is ever populated, everything other row exists but is empty!

 
if (row > 0)
                    {
                        dgProfiles.Rows.Add();
                        row++;
                    }
                    if ((currentProfile == string.Empty) || (profRow.SchoolProfileCode != currentProfile))
                    {
                        dgProfiles.Rows[row].Cells[0].Value = profRow.SchoolProfileCodeDescription;
                        dgProfiles.Rows[row].Cells[0].Style.ApplyStyle(style);
                        currentProfile = profRow.SchoolProfileCode;
                        dgProfiles.Rows.Add();
                        row++;
                        dgProfiles.Rows[row].Cells[0].Value = profRow.SchoolProfileAnswer;
                    }
                    else
                    {
                        dgProfiles.Rows[row].Cells[0].Value = profRow.SchoolProfileAnswer;
                    }

Open in new window


Any help is appreciated!

thanks
ASKER CERTIFIED SOLUTION
Avatar of RonCraig_101
RonCraig_101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kinton
kinton

ASKER

Superstar!  thanks so much, perfect.