Hope this helps
It does not seem to help.
When i try to go and get the validators they are always return "nothing" in the findcontrol...
This is my statement for the find:
Private Sub DG_Teams_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_Teams.ItemCommandIf e.CommandName = "EDIT" Then
DG_Teams.EditItemIndex = e.Item.ItemIndex
DG_Teams.ShowFooter = False
CV_E_TEAM_T_START_DAT = CType(e.Item.FindControl("CV_E_TEAM_T_START_DAT1"), CustomValidator) --> RETURNS NOTHING
CV_E_TEAM_T_END_DAT = CType(e.Item.FindControl("CV_E_TEAM_T_END_DAT1"), CustomValidator) --> RETURNS NOTHING
Inside the Edit cell in the DG_Teams datagrid i have the customvalidators with those ids ( "CV_E_TEAM_T_START_DAT1" and "CV_E_TEAM_T_END_DAT1" )
How is this possible? Damnnnnnnnnnnnnnnnn!!!!
If your validators are defined in the EditItemTemplate then before you can access them you need to rebind your grid - simply setting the value of EditItemIndex will not help. In addition to this, if you rebind your grid in ItemCommand after setting the EditItemIndex and re-binding the grid, you will not be able to use e.Item to access the DataGridItem which is in edit mode because when you re-bind the grid the Items collection of the grid is cleared and re-created. So you would have to do this:
....
DG_Teams.EditItemIndex = e.Item.ItemIndex
DG_Teams.ShowFooter = False
DG_Teams.DataSource = ......
DG_Teams.DataBind()
CV_E_TEAM_T_START_DAT = CType(DG_Teams.Items(DG_Teams.EditItemIndex).FindControl("CV_E_TEAM_T_START_DAT1"), CustomValidator)
to access the validator in the edit template.
If you need to access the validator just to set it's event handler i still suggest you do that in html as an attibute of the control
Cheers
Strangly enough i think i had override that situation.
But your method is the solution for sure ;) But i am using a user control and the databinding and datasourcing is done in another place because of the other functions so...
I really thank you for the solution, if i cant get it to work with my override i think i will have todo the binding that way.
Best Regards,
Luis Simoes
No comments:
Post a Comment