Wednesday, August 11, 2010

How can i Validate a Datagrid??????

I need to check during Editable mode of Datagrid that it should accept only numbers??????? how can i accomplish that....???How can i Validate a Datagrid??????
1. Make sure you have a validation function set up for updates in aspx page (mine is called DataUpdateCO):








%26lt;ASP:DATAGRID id=';MyChangeOverDataGrid'; runat=';server'; OnUpdateCommand=';DataUpdateCO'; BackColor=';LightBlue';%26gt;





2. Do validation by using ';.FindControl'; from the DataGridCommandEventArgs obj. My controls name is ';CO_ID';.








Sub DataUpdateCO(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)





Dim txtID As Integer = CInt(CType(E.Item.Cells(0).FindControl(';鈥?Label).Text)





If txtID = ';'; then


Msg.TExt = ';Error the ID is empty!


'do not update the grids data and re-bind


Else


'update the drids data and re-bind


End IF





End SubHow can i Validate a Datagrid??????
Use regular expression validator control
  • love myspace
  • myspace girl
  • No comments:

    Post a Comment