Problem with Data Grid

Problem with Data Grid

am 17.04.2008 09:56:43 von Ashwin

I have a Data Grid to display employee names and codes. On clicking a
button (outside the datagrid) I perform some calculations which sets
the fields of other columns in the datagrid.
The problem I am facing is that not all columns are filled with values
resulting from the calculations. Only the first few rows are being
filled with results.

------------------------------------------------------------ ------------------------------------------------------------ ---------------------
The datagrid code follows :

PageSize="5" AutoGenerateColumns="False"
BorderStyle="Groove">
BackColor="#B0C4DE">
Size="Smaller" Font-Names="Arial" Font-
Bold="True" HorizontalAlign="Center"
ForeColor="#FAFAD2"
BackColor="#4682B4">


HeaderText="Employee Id">
ForeColor="Black">



asp:Label>





EditItemTemplate>

HeaderText="Employee Name">
ForeColor="Black">



asp:Label>





EditItemTemplate>

HeaderText="Worked Days">
HorizontalAlign="Center" ForeColor="Black"> ItemStyle>








EditItemTemplate>

HeaderText="Off Days">
HorizontalAlign="Center" ForeColor="Black"> ItemStyle>








EditItemTemplate>

HeaderText="Holidays Payable">
HorizontalAlign="Center" ForeColor="Black"> ItemStyle>








EditItemTemplate>

HeaderText="Holiday ( Double_Salary)">
HorizontalAlign="Center" ForeColor="Black"> ItemStyle>








EditItemTemplate>

HeaderText="Payable Leave Days">
HorizontalAlign="Center" ForeColor="Black"> ItemStyle>








EditItemTemplate>

HeaderText="Total Pay Days">
HorizontalAlign="Center" ForeColor="Black"> ItemStyle>








EditItemTemplate>


Mode="NumericPages">


------------------------------------------------------------ ------------------------------------------------------------ --------------------

------------------------------------------------------------ ------------------------------------------------------------ --------------------
code to fill in the columns :

Private Sub btnCal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCal.Click
On Error GoTo er
If txtDateFrom.Text = "" Or txtDateTo.Text = "" Then
Call MessageBox("Date are Blank")

Else
For Each ditem In dg1.Items
empcode = ditem.FindControl("ecode")
wdays = ditem.FindControl("workdays")
off = ditem.FindControl("offdays")
hol = ditem.FindControl("holiday")
hol2 = ditem.FindControl("Holiday2")
leav = ditem.FindControl("Leave")


wdays.Text =
working_days(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd"), empcode.Text)
off.Text =
off_days(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd"))
hol.Text =
holiday(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd")) -
(hol_with_1_sal(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd"), empcode.Text) +
hol_with_2_sal(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd"), empcode.Text))
hol2.Text =
hol_with_2_sal(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd"), empcode.Text)
leav.Text =
Leave_count(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd"), empcode.Text,
Session("AccCompID"), Session("AccBranchID")) -
hol_leav(Format(DateValue(txtDateFrom.Text), "yyyy-MM-dd"),
Format(DateValue(txtDateTo.Text), "yyyy-MM-dd"), empcode.Text,
Session("AccCompID"), Session("AccBranchID"))


Next
End If
Exit Sub
er:
Err.Clear()
Exit Sub

End Sub
------------------------------------------------------------ ------------------------------------------------------------ --------------------

Help Needed !
Thank You.