Click here to Skip to main content
15,891,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends,



I am working on a attendance project, and I have three columns

1.Employee Name

2.Session(Morning / evening)

3. Jan 1 to Jan 31

example:



Empname Session Jan1 Jan2 Jan 3............... Jan 31

Rajesh Morning P A P

Evening P P P

Mohan Morning A P A

Evening A A P

Karthick Morning P P P

Evening P P P



I want to achieve this. I am pretty new to programming. I already bind days in a month. Now I wanna bind the empname by using row span. and want to bind Morning & Evening in a for until the end of the record.

code:
private void BtnClick_Click_1(object sender, EventArgs e)
        {

 dgAttendance.Columns.Clear();
            GetData("select empname from employee");
            DataGridViewColumn cb = new DataGridViewColumn();
            DataGridViewCell cell = new DataGridViewTextBoxCell();
            cb.HeaderText = "Session";
            cb.Name = "Session";
            cb.Visible = true;
            cb.Width = 70;
            cb.CellTemplate = cell;
            dgAttendance.Columns.Add(cb);
            int days = DateTime.DaysInMonth(Convert.ToInt32(cmbYear.SelectedItem), Convert.ToInt32(cboMonths.SelectedIndex + 1));
            for (int i = 1; i <= days; i++)
            {

                DataGridViewColumn cb1 = new DataGridViewColumn();
                DataGridViewCell cell1 = new DataGridViewTextBoxCell();
                cb1.HeaderText = Convert.ToString(cboMonths.Text) + i;
                cb1.Name = Convert.ToString(cboMonths.SelectedIndex) + i;
                cb1.Visible = true;
                cb1.Width = 70;
                cb1.CellTemplate = cell1;
                dgAttendance.Columns.Add(cb1);

            } }
Posted
Updated 27-Aug-10 0:48am
v2

1 solution

ok..Im not understanding your question pretty well..but I suppose you want to create a relation between the datarow members (a sort of merging multiple rows)..in that case you would need to call the DataRelation and DataColumn classes.

Read the below link and it would give you much insight into it..Its pretty simple and easy :)

http://msdn.microsoft.com/en-us/library/system.data.datarelation.aspx[^]
 
Share this answer
 
Comments
rajeshborn4u 30-Aug-10 9:37am    
Thanks for your suggestion.

Let me be clear what I want. I am developing a attendance project where every employee has two sessions, Morning and evening. So in the grid row we shall one employee and two sessions in a row. so that we can enter for both sessions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900