I have a PreRender event to set the width of my textbox when the Edit button is pressed on my grid here is the code:
Private Sub grdPBC_PreRende r(ByVal sender As Object, ByVal e As System.EventArg s) Handles grdPBC.PreRende r
If grdPBC.EditItem Index > -1 Then
Dim tbx As TextBox
tbx = CType(grdPBC.It ems(grdPBC.Edit ItemIndex).Cell s(4).Controls(0 ), TextBox)
tbx.Width = Unit.Pixel(50)
tbx = CType(grdPBC.It ems(grdPBC.Edit ItemIndex).Cell s(5).Controls(0 ), TextBox)
tbx.Width = Unit.Pixel(50)
End If
End Sub
So I bind the data to the grid and when you click on the edit button the width of the two textboxes are 50px. Perfect
But now after I bind the data to the grid I need to add data to one of the colomns, so I use a For Loop to go through the grid and add the data manually
Here is that code:
Dim dgItem As DataGridItem
Dim icount As Integer
Dim dGrandTotal As Double
For Each dgItem In grdPBC.Items
Dim cls As New ClassLibrary1.u sp_GetPBCTotalF orMonth
cls.Execute(Con figurationSetti ngs.AppSettings ("ConnectionStr ing"), grdPBC.Items(ic ount).Cells(0). Text, ddMonth.Selecte dValue, ddYear.Selected Value, txtFirstFriday. Text, dGrandTotal)
grdPBC.Items(ic ount).Cells(4). Text = Format(dGrandTo tal, "$##,##0.00 ")
icount = icount + 1
Next
Again that works fine. But if I now click on the Edit button the PreRender call throws an error on the line:
tbx = CType(grdPBC.It ems(grdPBC.Edit ItemIndex).Cell s(4).Controls(0 ), TextBox)
The error is:
"Run-time exception thrown : System.Argument OutOfRangeExcep tion - Specified argument was out of the range of valid values. Parameter name: index"
The other textbox in the PreRender event does not produce that error.
Please help.
Thank You
MutlyP
Private Sub grdPBC_PreRende r(ByVal sender As Object, ByVal e As System.EventArg s) Handles grdPBC.PreRende r
If grdPBC.EditItem Index > -1 Then
Dim tbx As TextBox
tbx = CType(grdPBC.It ems(grdPBC.Edit ItemIndex).Cell s(4).Controls(0 ), TextBox)
tbx.Width = Unit.Pixel(50)
tbx = CType(grdPBC.It ems(grdPBC.Edit ItemIndex).Cell s(5).Controls(0 ), TextBox)
tbx.Width = Unit.Pixel(50)
End If
End Sub
So I bind the data to the grid and when you click on the edit button the width of the two textboxes are 50px. Perfect
But now after I bind the data to the grid I need to add data to one of the colomns, so I use a For Loop to go through the grid and add the data manually
Here is that code:
Dim dgItem As DataGridItem
Dim icount As Integer
Dim dGrandTotal As Double
For Each dgItem In grdPBC.Items
Dim cls As New ClassLibrary1.u sp_GetPBCTotalF orMonth
cls.Execute(Con figurationSetti ngs.AppSettings ("ConnectionStr ing"), grdPBC.Items(ic ount).Cells(0). Text, ddMonth.Selecte dValue, ddYear.Selected Value, txtFirstFriday. Text, dGrandTotal)
grdPBC.Items(ic ount).Cells(4). Text = Format(dGrandTo tal, "$##,##0.00 ")
icount = icount + 1
Next
Again that works fine. But if I now click on the Edit button the PreRender call throws an error on the line:
tbx = CType(grdPBC.It ems(grdPBC.Edit ItemIndex).Cell s(4).Controls(0 ), TextBox)
The error is:
"Run-time exception thrown : System.Argument OutOfRangeExcep tion - Specified argument was out of the range of valid values. Parameter name: index"
The other textbox in the PreRender event does not produce that error.
Please help.
Thank You
MutlyP